/*
姓名:高万禄
名称:求next数组
日期:2020/2/4
*/
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
char test[11];
int next[11],j=1,k=0;
scanf("%s",test);
next[1]=0;
while(j<11)
{
if(k==0||test[k]==test[j])
{
next[++j]=++k;
}
else
{
k=next[k];
}
}
for(j=1;j<11;j++)
{
printf("%-3d",next[j]);
}
printf("\n");
return 0;
}
18 string pattern matching algorithm for the next array kmp
Guess you like
Origin blog.csdn.net/qq_45812941/article/details/104413682
Recommended
Ranking