字符串统计
来源:互联网 发布:ubuntu安装优麒麟市场 编辑:程序博客网 时间:2024/06/05 23:52
#include<stdio.h>
#include<string.h>
main(){
int n,i,j,len,w;
char a[1000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",a);
len=strlen(a);
w=0;
for(j=0;j<len;j++)
{
if(a[j]<='9'&&a[j]>='0')
w++;
}
printf("%d\n",w);
}
}
#include<string.h>
main(){
int n,i,j,len,w;
char a[1000];
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%s",a);
len=strlen(a);
w=0;
for(j=0;j<len;j++)
{
if(a[j]<='9'&&a[j]>='0')
w++;
}
printf("%d\n",w);
}
}
Problem Description
对于给定的一个字符串,统计其中数字字符出现的次数。
Input
输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。
Output
对于每个测试实例,输出该串中数值的个数,每个输出占一行。
Sample Input
2asdfasdf123123asdfasdfasdf111111111asdfasdfasdf
Sample Output
69
0 0
- 统计字符串
- 统计字符串
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 统计字符串
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- windows下广度和深度目录遍历
- JS常用的标准函数
- 双拼top域名释义能力强、使用范围广
- 约束的属性和方法
- Android各类资源XML格式定义与使用
- 字符串统计
- android 4.4 高通平台开发笔记
- TOP域名细数数字域名的魅力
- sqoop1.99.4的安装和使用
- 老域名建站没有想象的那么美好
- UIButton的以下开发者不长用的方法。。。。。。。。。
- LeetCode OJ 之 Binary Tree Postorder Traversal (二叉树的后序遍历)
- Null value was assigned to a property of primitive type setter of"原因及解决方
- MongoDB运行状态、性能监控,分析