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;
}
#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 2017 字符串统计
- hdoj 2017 字符串统计 (水)
- C++ hdoj 2017 字符串统计
- hdoj-2017 字符串统计【字符串】
- HDOJ 2017 字符串统计
- hdoj2017 字符串统计
- HDOJ 2017 字符串统计
- Hdoj2017_字符串统计
- ACM--数字个数--HDOJ 2017--字符串统计
- hdoj-2017-字符串统计(解题报告)
- hdoj.2017 字符串统计 20140724
- HDOJ 2017 字符串统计
- HDOJ2017 字符串统计
- HDOJ2017 ( 字符串统计 ) 【水题】
- 去哪儿2017校园招聘笔试题——统计字符串中最先出现三次的字符
- HDOJ 1004(字符串分类统计)
- hdoj 字符串统计
- hdoj-2030 汉字统计【字符串&&水】
- 【杭电-oj】-2017-字符串统计(字符串-string)
- 字符串统计 HDU - 2017