http://acm.hdu.edu.cn/showproblem.php?pid=2087
View Code
#include<iostream>
using namespace std;
int main()
{
char a[1001],b[1001];
int i,j;
while(cin>>a)
{
if(a[0]=='#') break;
cin>>b;
int L1=strlen(a);
int L2=strlen(b);
int sign=0 , flag=0;
i=sign,j=0;
while(i<L1)
{
if(a[i] == b[j])
{
i++;
j++;
if(j==L2)
{
flag++;
j=0;
sign=i;
}
}
else
{
j=0;
sign++;
i=sign;
}
}
cout<<flag<<endl;
}
return 0;
}