HDOJ 2017 字符串统计

来源:互联网 发布:英雄无敌5 mac版 编辑:程序博客网 时间:2024/05/18 16:16

        统计出现的数字字符,遍历统计就好。

#include <cstdio>const int MAX_SIZE = 10000;char words[MAX_SIZE];//#define yangyuanint 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;}


原创粉丝点击