题解 | #String Matching#
String Matching
https://www.nowcoder.com/practice/00438b0bc9384ceeb65613346b42e88a
#include <iostream>
#include <cstring>
using namespace std;
string a,b;
int main() {
cin >> a >> b;
int j, t, count = 0;
bool sign = true;
// for(int i = 0; i < a.size(); i++)
// {
// j = 0;
// if(a[i] == b[j])
// {
// t = i;
// sign = true;
// for(j = 0; j < b.size(); j++)
// {
// if(a[t] != b[j])
// sign = false;
// t++;
// }
// if(sign) count++;
// }
// }
for(int i = 0; i < a.size(); i++)
{
if(a.substr(i,b.size()) == b)
count++;
}
cout << count << endl;
}
// 64 位输出请用 printf("%lld")

