题意:给出两个字符串,a和b,在b中删除a串,删除多少次不能在删除了。
#include<stdio.h>
#include<string.h>
char b[520000],a[2000],st[520000];
int main()
{
while(scanf("%s %s", a, b) != EOF) {
int ans = 0;
int tp = 1;
int len = strlen(a);
for(int i = 0; b[i]; i++) {
st[tp-1] = b[i];
if(tp >= len) {
st[tp] = 0;
if(strcmp(st+tp-len, a) == 0) {
tp -= len;
ans++;
}
}
tp++;
}
printf("%d\n", ans);
}
return 0;
}