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

发布于 2024-09-13 23:19:43 字数 441 浏览 2 评论 0原文

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.
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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

兮子 2024-09-20 23:19:43

您需要的是字符串匹配算法,通常使用动态编程实现(参见

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

What you need is a string matching algorithm, usually implemented using dynamic programming (see here).

I'd highly suggest using a library that performs the diff instead of implementing it yourself.

冰魂雪魄 2024-09-20 23:19:43

虽然通常使用字母而不是整数来完成,但计算 Levenstein 距离的常用算法在这里应该与通常应用的地方一样有效。

Though it's normally done with letters instead of integers, the usual algorithm for computing the Levenstein distance should work just as well here as where it's usually applied.

顾铮苏瑾 2024-09-20 23:19:43

我是 C++ 差异库开发人员。

http://code.google.com/p/dtl-cpp/

使用我的 diff 库,可以计算两个序列之间的差异。

使用方法请参见examples/intdiff.cpp。

I'm diff library developer with C++.

http://code.google.com/p/dtl-cpp/

Using My diff library, it is possible to calculate the difference between two sequences.

Please see examples/intdiff.cpp about how to use.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文