int getLCSLength(string str1, string str2){
if(str1.size()==0 || str2.size()==0)
return 0;
int** temp=new int*[str1.size()];
for(int i=0;i<str1.size();++i)
temp[i]=new int[str2.size()];
int max=0;
for(int i=0;i<str1.size();++i)
for(int j=0;j<str2.size();++j){
if(str1[i]==str[2]){
if(i>0&&j>0)
temp[i][j]=temp[i-1][j-1]+1;
else
temp[i][j]=1;
if(temp[i][j]>max)
max=temp[i][j];
}
else
temp[i][j]=0;
}
return max;
}
求两个字符串的最长公共子串的长度
最新推荐文章于 2020-12-22 12:55:46 发布