65,206
社区成员
发帖
与我相关
我的任务
分享
void MakeNext(char *buff, int len, int *next)
{
int i = 0, k = -1;
next[0] = -1;
while(i < len - 1)
{
while(k >= 0 && buff[i] != buff[k])
k = next[k];
i++;
k++;
#define IMPROVED
#ifdef IMPROVED
if(buff[i] == buff[k])
next[i] = next[k];
else
next[i] = k;
#else
next[i] = k;
#endif
}
}