题目1094:String Matching
http://ac.jobdu.com/problem.php?pid=1094
View Code
1 #include<iostream> 2 #include<algorithm> 3 #include<string.h> 4 #include<string> 5 #include<vector> 6 using namespace std; 7 8 int main() 9 { 10 vector<string> vec; 11 string s1,s2; 12 while(cin>>s1) 13 { 14 cin>>s2; 15 int count=0,len1=s1.size(),len2=s2.size(); 16 int i=0; 17 for(i=0;i<=len1-len2;++i) 18 { 19 string s3(s1,i,len2); 20 if(s2==s3) 21 ++count; 22 } 23 cout<<count<<endl; 24 } 25 return 0; 26 }