您的位置:首页 > 其它

HDOJ 2017 字符串统计

2017-12-21 22:26 225 查看
        统计出现的数字字符,遍历统计就好。

#include <cstdio>

const int MAX_SIZE = 10000;
char words[MAX_SIZE];
//#define yangyuan
int main()
{
#ifdef yangyuan
freopen("in", "r", stdin);
#endif // yangyuan
int n;
scanf("%d", &n);
getchar();
while (n--)
{
fgets(words, MAX_SIZE, stdin);
int count = 0;
for (int i = 0; i < MAX_SIZE && words[i] != '\0'; i++)
{
if (words[i] >= '0' && words[i] <= '9')
count++;
}
printf("%d\n", count);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  HDOJ