#include<stdio.h>
#include<malloc.h>
#include<string.h>
#include"DString.h"
void GetNext(DString T,int next[])
{
int j=1,k=0;
next[0]=-1;
next[1]=0;
while(j<T.length - 1)
{
if(T.str[j]==T.str[k])
{
next[j+1]=k+1;
j++;
k++;
}
else if(k==0)
{
next[j+1]=0;
j++;
}
else k=next[k];
}
}
int KMPIndex(DString S, int start, DString T, int next[])
{
int i = start, j = 0, v=0;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载