1227:字符串统计
来源:互联网 发布:时时彩开奖软件 编辑:程序博客网 时间:2024/06/09 14:08
1227:字符串统计
Description
对于给定的一个字符串,统计其中数字字符出现的次数。
Input
输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。
Output
对于每个测试实例,输出该字符串中数值的个数,每个输出占一行。
Sample Input
2
asdfasdf123123asdfasdf
asdf111111111asdfasdfasdf
Sample Output
6
9
#include<iostream>#include<string.h>#include<stdio.h>using namespace std;int main(){ int n,i,N; cin>>N; while(N--) { string ch; cin>>ch; n=ch.length(); int count=0; for(i=0;i<n;i++) { if(ch[i]>=48&&ch[i]<=57) count++; } cout<<count<<endl; } return 0;}
阅读全文
0 0
- 1227: 字符串统计
- 1227:字符串统计
- 统计字符串
- 统计字符串
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 字符串统计
- 统计字符串
- 字符串统计
- 字符串统计
- 用Python做简易的中文词云
- iOS判断
- c#实现类似QQ的简单聊天程序,可支持广域网。
- [初学笔记] continue 和 break 语句, return 语句
- Java打乱数组顺序
- 1227:字符串统计
- 【Python那些事儿】判断文件/文件夹是否存在的方法
- 依赖注入(DI)和控制反转(IOC)的详细分析
- c语言与java的区别与各自的优势
- spring-boot配置html模板引擎freemarker、thymeleaf
- mysql 字段值逗号分割后sql匹配
- C# 深拷贝
- 6174问题(二)
- Andriod---创建自己的内容提供器