您的位置:首页 > 其它

hdu 2017 字符串统计

2015-10-12 14:17 288 查看
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2017
题目大意:统计数字出现的次数,但是要注意输入字符时,要清流。。要吸收一个回车。还有注意输入时的格式~

1 #include<stdio.h>
2 int main()
3 {
4     int n;
5     char c;
6     scanf("%d\n",&n);
7     while(n--)
8     {
9         int a=0;
10         while((c=getchar())!='\n')
11         {
12             if(c>='0'&&c<='9')
13                 a++;
14         }
15         printf("%d\n",a);
16     }
17 }


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: