解题思路:
注意事项:
参考代码:
#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 人评分
C语言训练-8除不尽的数 (C语言代码)暴力解法,答案只有一个,直接输出就好了浏览:1015 |
求圆的面积 (C语言代码)浏览:1269 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:599 |
C语言训练-尼科彻斯定理 (C语言代码)浏览:464 |
WU-小九九 (C++代码)浏览:1684 |
【偶数求和】 (C语言代码)浏览:431 |
数组与指针的问题浏览:716 |
C语言程序设计教程(第三版)课后习题11.5 (C语言代码)浏览:997 |
C语言训练-列出最简真分数序列* (C语言代码)浏览:598 |
【魔板】 (C++代码)浏览:1158 |