HDU 4847 陕西邀请赛A(水)

时间:2022-01-30 04:45:15

HDU 4847 Wow! Such Doge!

pid=4847" style="">题目链接

题意:给定文本,求有几个doge,不区分大写和小写

思路:水题。直接一个个读字符每次推断就可以

代码:

#include <stdio.h>
#include <string.h> char c;
char a[5]; int main() {
a[5] = '\0';
int ans = 0;
while ((c = getchar()) != EOF) {
if (c >= 'a' && c <= 'z') c -= 32;
a[3] = c;
if (strcmp(a, "DOGE") == 0) ans++;
for (int i = 0; i < 3; i++)
a[i] = a[i + 1];
}
printf("%d\n", ans);
return 0;
}