正在加载图片...
36 KMP算法 int Inder_MP(sString S, sString T, int pos)1 ∥利用糗式申的ne函数求丌在主申S中第poa个字符之后的位置的 ∥p算法。其中,T非空,1≤pos≤ strEngth(S)。 j=1; Mh1·(i<‘S[0]j<=r[0]) 0s山]-r){*++j ∥继续比较后继字符 next[i ∥模式串向右移动 f(>型[0])rts1實0]; ∥匹配成功 alae retum 0t ∥ndex.8 int Index(sstring S, sString T, int poa)I ∥返国子串T在主串8中第pa个字符之后的位量。若不存在则函数值为0。 ∥其中,T非空,1≤po≤ strEngth($) Mh】(<=S[0]最&1<=r[oJ) (S[=丌++1+}∥继续比较后繼字符 1m{1=1-j+2;j=1;}∥指针后退重新开始匹配 (j>r[0]) TO nturn 0 ∥ Index
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有