首页 > 编程语言 > 详细

C语言多种方法求解字符串编辑距离问题的代码

时间:2019-04-10 15:55:32      阅读:155      评论:0      收藏:0      [点我收藏+]

把做工程过程经常用的内容记录起来,如下内容段是关于C语言多种方法求解字符串编辑距离问题的内容。


{
if(xbeg > xend)
{
if(ybeg > yend)
return 0;
else
return yend - ybeg + 1;
}
if(ybeg > yend)
{
if(xbeg > xend)
return 0;
else
return xend - xbeg + 1;
}
if(ptrX[xend] == ptrY[yend])
{
return calDistance1(ptrX,xbeg,xend-1,ptrY,ybeg,yend-1);
}else
{
int t1 = calDistance1(ptrX,xbeg,xend-1,ptrY,ybeg,yend);
int t2 = calDistance1(ptrX,xbeg,xend,ptrY,ybeg,yend-1);
int t3 = calDistance1(ptrX,xbeg,xend-1,ptrY,ybeg,yend-1);
t1 = t1 < t2 ? t1 : t2;
return (t1 < t3 ? t1 : t3) + 1;
}
}




 

C语言多种方法求解字符串编辑距离问题的代码

原文:https://www.cnblogs.com/SHUN019/p/10683557.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!