xdoj288 求一个顺寻串的next函数值

问题描述:

​ 所设计的程序能够通过编译。并能够实现从输入一个长度为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<

你可能感兴趣的:(数据结构,c++)