re: KMP算法 lstar 2011-04-21 10:55
樓主這里有問(wèn)題吧,
while(j<strlen(s2))
{
//臨界條件 j=strlen(s2) -1;
if(i==-1||s2[i]==s2[j]){
i++; j++;
// j++后 j=strlen(s2);
//next[j] 數(shù)組越界了?
next[j]=i;
}
else i=next[i];
}
while(j<strlen(s2))
{
//臨界條件 j=strlen(s2) -1;
if(i==-1||s2[i]==s2[j]){
i++; j++;
// j++后 j=strlen(s2);
//next[j] 數(shù)組越界了?
next[j]=i;
}
else i=next[i];
}