NYOJ 5 字符串处理 find()函数应用
http://acm.nyist.net/JudgeOnline/problem.php?pid=5
1 #include<stdio.h> 2 #include<iostream> 3 #include<string> 4 using namespace std; 5 int main() 6 { 7 string s1,s2; 8 int t; 9 cin>>t; 10 while(t--) 11 { 12 cin>>s1>>s2; 13 int m; 14 m=s2.find(s1,0); 15 int ans=0; 16 while(m!=string::npos) 17 { 18 19 ans++; 20 m=s2.find(s1,m+1); 21 //printf("m=%d\n",m); 22 } 23 printf("%d\n",ans); 24 } 25 //system("pause"); 26 return 0; 27 }