//BF 算法 int BFmatch(char *s,char *p) { int i,j; i = 0; while(i<strlen(s)) { j = 0; while(s[i] == p[j] && j<strlen(p)) { i++; j++; } if(j == strlen(p)) return i - strlen(p); i = i - j + 1; // 指针 i回溯 } return -1; }