串匹配BM算法、KMP算法、BF算法

发布时间 : 星期六 文章串匹配BM算法、KMP算法、BF算法更新完毕开始阅读

. } { printf(\return 0; } printf(\ return 0; } KMP算法: #include #include #include main() { .

char s[100]; char t[100]; . . int i,a,b,m,n; printf(\scanf(\printf(\scanf(\m=strlen(s); n=strlen(t); printf(\for(a=0;a<=m-n;a++) { b=0; while(s[a]==t[b]&&b!=n) { } if(b==n) { printf(\return 0; a++; b++; } else { } if(b=-1) {b++;} else return 0; b=b+1; a=a-b; . } printf(\ return 0; } BM算法: #include using namespace std; #include #include static int time=0; //dist函数 int dist(char ch,char *T) { int k=-1,t1; .

. t1=strlen(T); for(int i=0;i=0&&S[i]==T[j]) { i--; .

j--;

联系合同范文客服:xxxxx#qq.com(#替换为@)