#include <stdio.h>
#define MAXN 201 int maxsubstr(char *s1,char *s2) { int max,i,j,k,len1,len2,t,m; char *p,*q; len1=strlen(s1); len2=strlen(s2); if(len1>=len2) { p=s1;q=s2; } else { p=s2;q=s1; t=len1; len1=len2; len2=t; } for(i=len2;i>=1;i--) { for(k=0;k+i<=len1;k++) { for(m=0;m+i<=len2;m++) for(j=0;j<i && *(p+k+j)==*(q+j+m) ;j++); if(j==i) { max=i; return max; } } } return 0;/*无公共子串*/ } int main() { char s1[MAXN],s2[MAXN]; gets(s1); gets(s2); printf("%d/n",maxsubstr(s1,s2)); return 0; |