题解 | #String Matching#
String Matching
https://www.nowcoder.com/practice/00438b0bc9384ceeb65613346b42e88a
#include <iostream> #include <string> using namespace std; int main() { string a, b; while (cin >> a >> b) { int cnt = 0; for (int i = 0; i < a.size() - b.size() + 1; i++) { string temp = a.substr(i, b.size()); if (temp == b) cnt++; } cout << cnt << endl; } }