所设计的程序能够通过编译。并能够实现从输入一个长度为n的顺序串str,并求出顺序串str的next值。
首先输入串的长度n,然后输入顺序串str.
输出str的next值,以空格分隔。
8
a b c a b c b c
-1 0 0 0 1 2 3 0
#include
#include
using namespace std;
void get_next(char str[],int next[],int n,int m)
{
int i=1,j=0;
next[1]=0;
while(i>n;
char str[n+1];
str[0]=n;
int i,j;
for(i=1;i<=n;i++)
{
cin>>str[i];
}
int next[n+1];
get_next(str,next,n+1,n+1);
for(i=1;i<=n;i++)
cout<