C - 字符串统计 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
来源:互联网 发布:ec软件下载 编辑:程序博客网 时间:2024/06/02 19:43
Description
对于给定的一个字符串,统计其中数字字符出现的次数。
Input
输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。
Output
对于每个测试实例,输出该串中数值的个数,每个输出占一行。
Sample Input
2asdfasdf123123asdfasdfasdf111111111asdfasdfasdf
Sample Output
69
#include<stdio.h>
int main(){
int n;
scanf("%d\n",&n); //输入后面有转行,不仅在输出中,输入中也有。
char str[10000]; //虽然不知道字符串的长度,但是不用动态开辟。!!n在编译的时候并没有赋值,不能作为数组下标
while(n--)
{
int i=0,counts=0;
gets(str);
while(str[i]!='\0') //字符串结束的表示系统自动带0
{
if((str[i]<='9')&&(str[i]>='0'))
counts++;
i++;
}
printf("%d\n",counts);
}
return 0;
}
0 0
- C - 字符串统计 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- E - 排序 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- C - Climbing Worm Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- B - 素数判定 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- D - 折线分割平面 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- L - 空心三角形 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- M - 人见人爱A+B Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- N - 人见人爱A-B Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- A - 求奇数的乘积 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Sta
- A - A+B for Input-Output Practice (V) Time Limit:1000MS Memory Limit:32768KB 64bit IO Form
- SDUTACM Anohana: The Flower We Saw That Day Time Limit: 1000MS Memory Limit: 65536KB
- 数据结构实验之二叉树三:统计叶子数 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description
- 1-1 欢迎来的C++世界 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Description 通
- //Sticks Time Limit: 1000MS Memory Limit: 10000K POJ//
- Eddy的难题 Time Limit: 1000MS Memory Limit:
- 数据结构实验之查找一:二叉排序树 Time Limit: 400MS Memory Limit: 65536KB
- 树-堆结构练习——合并果子之哈夫曼树 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Discuss Problem Descrip
- 算符优先系列之(一)Firstvt和Lastvt集 Time Limit: 1000MS Memory Limit: 65536KB Submit Statistic Problem Descri
- 关于cocoa pods安装的那些事
- HTTP长连接与短连接
- 坏盘导致Kafka故障一例
- 类的继承、拷贝构造函数
- 编程之美之数组分割
- C - 字符串统计 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
- 易语言学习第十二课
- SharedPreferences的使用
- Activity的生命周期
- [leetcode] Longest Substring Without Repeating Characters
- #leetcode#83 Remove Duplicates from Sorted List
- Camtasia Studio实现画中画视频课件制作方案
- 浙大 PAT Advanced level 1010. Radix
- hdu-5120(两圆相交面积)