#include<stdio.h>
#include<string.h>
int main(){
char a[100];
char b[100];
gets(a);
gets(b);
int count=0;
int i,j;
for(i=0;i<strlen(a);i++){
for(j=0;j<strlen(b);j++){
if(a[i+j]!=b[j]){
break;
}
}
if(j==strlen(b)){
count++;
}
}
printf("%d",count);
return 0;
}
ps:开始总是把问题想的很复杂,写的也很复杂-_-||
#include<stdio.h>
int main(){
char a[100];
char b[100];
gets(a);
gets(b);
char *p1=a;
char *p2=b;
int count=0;
while(*p1!='\0'){
if (*p1 == *p2)
{
p1++;
p2++;
}
else{
p1++;
}
if(*p2=='\0'){
count++;
p2=b;
}
}
printf("%d",count);
}