链接:
http://acm.hdu.edu.cn/showproblem.php?pid=4847
题意:
Now, Doge wants to know how many words “doge” are there in a given article. Would you like to help Doge solve this problem?
思路:
暴力完事
代码:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
//#include <memory.h>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <math.h>
#include <stack>
#include <string>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <sstream>
#define MINF 0x3f3f3f3f
using namespace std;
typedef long long LL;
const int MAXN = 1e6+10;
char s[MAXN];
bool Check(int p)
{
if (s[p] != 'd' && s[p] != 'D')
return false;
if (s[p+1] != 'o' && s[p+1] != 'O')
return false;
if (s[p+2] != 'g' && s[p+2] != 'G')
return false;
if (s[p+3] != 'e' && s[p+3] != 'E')
return false;
return true;
}
int main()
{
int ans = 0;
while (gets(s))
{
int len = strlen(s);
for (int i = 0;i < len;i++)
if (Check(i))
ans++;
}
cout << ans << endl;
return 0;
}