void gongGongZiFuChuan( char str1[], char str2[], char result[])
{
unsigned long len1,len2;
unsigned long start;
unsigned long i, j,count;
count=0;
//初始化count
len1=strlen(str1);
//初始化len1
len2=strlen(str2);
//初始化len2
for (i=0; i<len1; i++) {
for(j=0;j<len2;j++){
unsigned long myi=i;
unsigned long myj=j;
int countX=0;
while (str1[i]==str2[j]) {
i++;
j++;
countX++;
}
if (countX>count) {
count=countX;
start=myi;
}
i=myi;
j=myj;
}
}
unsigned long z;
unsigned long t;
for (t=0,z=start; z<(start+count); z++,t++) {
result[t]=str1[z];
}
result[i]='\0';
}
最好能注释一下,万分感谢 |
|