题解 | #String Matching#
String Matching
https://www.nowcoder.com/practice/00438b0bc9384ceeb65613346b42e88a
#include <iostream> using namespace std; int main() { string t,p; cin>>t>>p; int res=0; for(int s=0;s<=t.size()-p.size();s++){ int j=0,k=s; while(j<p.size()&&t[k]==p[j]){ k++; j++; } if(j==p.size()) { res++; } } cout<<res<<endl; return 0; }