求教,统计哪个长字符串中‘as’的个数,怎么运行时31呢?求大侠们看看哈
#include<stdio.h>void main()
{
char a1[]={"asd asasdfg asd as zx67 asd mklo"},a2[]={"as"};
char *p,*p1;
int cent;
cent=0;
p=a1;
p1=a2;
while(*p)
{
while(*p1)
if(*p==*p1)
{
p++;
p1++;
}
else
break;
if(*p1=='\0')
cent++;
p++;
}
printf("%d",cent);
printf("\n");
}