字符串匹配的算法是怎样的?
字符串匹配的算法是怎样的?
字符串匹配 void NaiveStringMatching(char *t,char *p) { int n=Length(t); int m=Length(p); if(n { printf(\"Error:The P is longer than T!\\n\"); return; } bool find=true; printf(\"The string T is %s\\n\",t); printf(\"The string P is %s\\n\",p); for(int s=0;s { if(t[s+i]!=p[i]) { find=false; break; } } if(find) printf(\"Pattern occurs with shift:%d\\n\",s+1); } } int main() { char t[]=\"abcdebcg\"; char p[]=\"bcdebcg\"; NaiveStringMatching(t,p); return 0; }。
答:strcat(t, s+ i ); s[i]= 0; strcat(s, t );详情>>