2.1.求next和nextval的实现
代码:
int next_one(char *str, int len) {
int result = 1;
if(len == 1 || len == 0) return len;
for (size_t i = 1; i < len; i++)
{
if(compare(str, str+len-i, i)) {
result = i+1;
//break;
}
}
return result;
}
int next(char *str, int *arr) {
int count = size(str);
if(count == 1)
{arr[0] = 0; return count;}
for (size_t i = 0; i < count; i++)//i = len
{
arr[i] = next_one(str, i);
}
return count;
}
int nextval(char *str, int *arr) {
int count = size(str);
int k