#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void)
{
int next[6],i,j=1,k=0;
char text[6];
scanf("%s",text);
while(j<6)
{
if(k==0||text[j]==text[k])
{
k++;
j++;
if(text[j]==text[k])
{
next[j]=next[k];
}
else
{
next[j]=k;
}
}
else
{
k=text[k];
}
}
for(i=1;i<6;i++)
{
printf("%-3d",next[i]);
}
return 0;
}
19next算法改进nextval
猜你喜欢
转载自blog.csdn.net/qq_45812941/article/details/104413715
今日推荐
周排行