void get_nextval(char T[] int next[])
{
//求模式串T的next函数值并存入数组next
j = ; next[] = ; k = ;
while ( T[j+] != \ ) {
if (k = = || T[j] = = T[k]) {
++j; ++k;
if (T[j]!=T[k]) next[j] = k;
else next[j] = next[k];
}//if
else k = next[k];
}// while
}//get_nextval
KMP算法匹配的过程动画演示