int Count(char *const a,char *const b)
{//a为主串,b为子串
char *p=a,*q=b;
int count=0;
while(*p)
{
if ((*p==*q)&&(*q)) //匹配条件
{
p++; q++;
}
else //不匹配q要重置,并在主串中继续查找
{
p++; q=b;
}
if (!(*q)) //匹配后q要重置
{
count++;
q=b;
}
}
cout<<count;
}