gpt4 book ai didi

c++ - c++/mfc/STL 中两个数组的差异函数?

转载 作者:行者123 更新时间:2023-11-30 04:37:59 25 4
gpt4 key购买 nike

Diff function on two arrays (or how to turn Old into New) 

Example
One[]={2,3,4,5,6,7}
Two[]={1,2,3,5,5,5,9}

Example Result
Diff: insert 1 into One[0], One[]={1,2,3,4,5,6,7}
Diff: delete 4 from One[3], One[]={1,2,3,5,6,7}
Diff: modify 6 into 5 in One[4], One[]={1,2,3,5,5,7}
Diff: modify 7 into 5 in One[5], One[]={1,2,3,5,5,5}
Diff: append 9 into One[6], One[]={1,2,3,5,5,5,9}

Need code in c++/mfc/stl/c, Thanks.

最佳答案

您需要的是一个字符串匹配算法,通常使用动态规划实现(参见 here)。

我强烈建议使用执行差异的库而不是自己实现它。

关于c++ - c++/mfc/STL 中两个数组的差异函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3454394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com