概述

时间限制: 1 Sec 内存限制: 128 MB
题目描述
统计此字符串中字母、数字、空格和其它字符的个数, 只要结果,别输出什么提示信息。

输入
一行字符串
输出
统计数据,4个数字,空格分开。
样例输入 Copy
!@#$%^QWERT 1234567
样例输出Copy
5 7 4 6

答案:
#includeusing namespace std;int main(){ char a[1000]; cin.getline(a,1000); int l=strlen(a); int s[5]={0,0,0,0}; for(int i=0;i='A'&&a[i]<='Z')||(a[i]>='a'&&a[i]<='z')) s[1]++; else if(a[i]>='0'&&a[i]<='9') s[2]++; else if(a[i]==' ') s[3]++; else s[4]++; } for(int i=1;i<=3;i++) cout<
最后
以上就是温暖滑板为你收集整理的7-6 统计字符串中数字字符的个数_初级编程C++题:11H1355: 字符统计1的全部内容,希望文章能够帮你解决7-6 统计字符串中数字字符的个数_初级编程C++题:11H1355: 字符统计1所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复