void Index(char*str,char*instr,int strlength,int instrlength){
int i = 0,j = 0;
while(i<strlength&&j<instrlength){
if(str[i] == instr[j]){
i++;
j++;
}else{
i = i-j+1;
j = 0;
}
}
if(j=instrlength){
printf("true");
}else{
printf("false");
}
}
int main(int argc, char** argv) {
char p[] = "asdasdasd";
char q[] = "asd";
int l = strlen(p);
int r = strlen(q);
Index(p,q,l,r);
return 0;
}
字符串匹配BF算法
最新推荐文章于 2024-08-29 16:37:54 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)