函数kmp实现串的模式匹配,请在空格处将算法补充完整。
int kmp(sqstring *s,sqstring *t,int start,int next[]){
int i=start-1,j=0;
while(i<s->len&&j<t->len)
if(j==-1||s->data[i]==t->data[j]){
i++;j++;
}
else j= ;
if(j>=t->len)
return( );
else
return(-1);
next[j] i - t->len
-1 0
next[j] i - t -> len
next[j]
i- t->len
i-t->len
next[j] i-t->len+1
lll
i-j->len+1
j等于next,i
next[j];i-t->len
kk
hhh
next[j];
i - t->len;
j = next[j];
i-t->len+1;
i-t->len;
i-t.length
i-t.len
1.next[j]
2.i-t.len+1
i-t.len+1
j - next[j]
i - j
j - t->len + 1
i-t->length+1
i-T->len+1
i-j+1
i-t->len+1
i - t -> len + 1
i-t->len+1 //j=0
realtian 回复 realtian: i - t->len +1
next[j] 、j - t->len
(1)next[j]
(2)i-t.length
用户登录可进行刷题及查看答案
登录后提交答案