标签:
abcxxxxabcxabcd
abcdxabcxxxxabcx
11
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<algorithm> 5 using namespace std; 6 char a[85],b[85]; 7 int check(char a[],char b[],int k){ 8 int l2=strlen(b+1); 9 for(int i=1;i<=k;i++) 10 if(a[i]!=b[l2-k+i]) return 0; 11 return 1; 12 } 13 14 int main(){ 15 // freopen("01.txt","r",stdin); 16 scanf("%s",a+1); 17 scanf("%s",b+1); 18 int l1=strlen(a+1),l2=strlen(b+1); 19 for(int i=min(l1,l2);i>=1;i--){ 20 if(check(a,b,i)||check(b,a,i)){ 21 printf("%d\n",i); 22 return 0; 23 } 24 } 25 return 0; 26 }枚举长度,正反模拟判断
标签:
原文地址:http://www.cnblogs.com/radiumlrb/p/5793626.html