#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
#define kuaidian ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 100 + 7, maxd = 1e8;
const ll mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
int n;
int ans = 0;
int main() {
char s[1050];
scanf("%d", &n);
for(int i = 0; i < n; ++i) {
scanf("%s", s);
ans = 0;
int len = strlen(s);
for(int j = 0; j+2 < len; ++j) {
if(s[j] == 'c' && s[j+1] == 'a' && s[j+2] == 't' ){
ans ++;
}
else if (s[j] == 'd' && s[j+1] == 'o' && s[j+2] == 'g'){
ans ++;
}
}
cout <<ans <<endl;
}
return 0;
}
ZOJ - 3957 Knuth-Morris-Pratt Algorithm
最新推荐文章于 2019-08-15 18:13:44 发布