QvQ


私信TA

用户名:927937414

访问量:28113

签 名:

还是好好学习吧

等  级
排  名 77
经  验 9399
参赛次数 9
文章发表 44
年  龄 19
在职情况 学生
学  校
专  业 软件工程

  自我简介:

还没学算法的弱鸡


解题思路:

注意事项:

参考代码:

#include <iostream>
#include <cstring>
using namespace std;
int BF(char *s,char *t){
	int i=0,j=0;
	while(i<strlen(s)&&j<strlen(t)){
		if(s[i]==t[j]){
			i++;
			j++;
		}
		else{
			i=i-j+1;
			j=0;
		}
	}
	if(j==strlen(t))
		return i-strlen(t)+1;
	return 0;
}
int main(){
	char str1[101],str2[101];
	while(cin>>str1>>str2){
		int add=BF(str1,str2);
		cout<<add<<endl;
	}
	return 0;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区