字符串中数字统计解题报告
2013-01-30 21:10
281 查看
Problem Description
对于给定的一个字符串,统计其中数字字符出现的次数。
Input
输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。
Output
对于每个测试实例,输出该串中数值的个数,每个输出占一行。
Sample Input
Sample Output
对于给定的一个字符串,统计其中数字字符出现的次数。
Input
输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。
Output
对于每个测试实例,输出该串中数值的个数,每个输出占一行。
Sample Input
2 asdfasdf123123asdfasdf asdf111111111asdfasdfasdf
Sample Output
6 9分析:水题不解释~原码:#include<stdio.h> #include<string.h> int main() { int n,len; char a[200]; scanf("%d",&n); getchar(); while(n--) { int k=0; gets(a); len=strlen(a); for(int j=0; j<=len; j++) { if(a[j]<='9'&&a[j]>='0') k++; } printf("%d\n",k); } return 0; }
相关文章推荐
- 字符串中数字统计解题报告
- (解题报告)HDU2017---字符串统计
- hdu 2017 字符串统计 解题报告
- 【LintCode】3.统计数字(Medium)解题报告
- 07noip 统计数字 解题报告
- 全国信息学奥林匹克联赛(NOIP2010)复赛 1.数字统计 解题报告
- hdoj-2017-字符串统计(解题报告)
- 1068统计数字解题报告
- Leetcode 357. Count Numbers with Unique Digits 统计没有重复数字的数 解题报告
- codevs 1164 || NOIP 2007 统计数字 模拟 解题报告
- 字符串的小案例:统计字符串中大写字母.小写字母.数字的个数
- 串结构练习——字符串连接 解题报告
- 回文字符串的判断解题报告
- 从终端获取一个字符串,分别统计其中大写字母、小写字母、数字及其它字符的个数。
- 统计字符串中有多少空格,数字,字母
- 对于给定的一个字符串,统计其中数字字符出现的次数。输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。
- 统计字符串中:各个数字、空白字符、以及其他所有字符出现的次数
- 函数统计输入字符串中字母,数字等个数。
- 洛谷1098 字符串的展开 解题报告
- 编写程序,当程序运行后,根据屏幕提示输入一个数字字符串,输入后统计有多少个偶数数字和奇数数字。