统计出其中英文字母、数字、空格和其他字符的个数
2014-12-15 19:33
316 查看
#include <iostream> #include<cstdio> using namespace std; int main() { char x[999]; char*p=x; int a=0,b=0,c=0,d=0; gets(x); while(*p) { if(('A'<=*p&&*p<='Z')||('a'<=*p&&*p<='z')) a++; else if('0'<=*p&&*p<='9') b++; else if(*p==' ') c++; else d++; p++; } cout<<a<<" "<<b<<" "<<c<<" "<<d; return 0; }
输出结果:
相关文章推荐
- 第九周-统计出其中英文字母、数字、空格和其他字符的个数
- 输入一行字符,分别统计出其中的英文字母,空格,数字和其他字符的个数
- ACM新秀赛模拟——统计出其中英文字母、数字、空格和其他字符的个数
- 输入一行字符,分别统计出其中的英文字母、空格、数字、和其他字符的个数
- 作业3(3)输入 15 个字符,统计其中英文字母、空格或回车、数字字符和其他字符的个数
- 第九周OJ总结<1>-统计出其中英文字母、数字、空格和其他字符的个数
- 输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数。
- 输入一行字符,分别统计其中英文字母、空格、数字和其他字符的个数
- 第九周OJ项目-统计出其中英文字母、数字、空格和其他字符的个数
- 输入一行字符,分别统计出其中英文字母 空格 数字 和其他字符的个数
- 输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数【while循环】
- 第九周练习--统计出其中英文字母、数字、空格和其他字符的个数
- 烟大ACM新秀赛 B统计出其中英文字母、数字、空格和其他字符的个数
- 输入一串字符,统计出其中的英文字母,空格,数字和其他字符
- 输入一行字符 分别统计其中英文字母 空格 数字 和其他字符的个数
- 华为oj_输入一行字符,分别统计出其中英文字母、空格、数字和其他字符的个数
- 输入一行字符,分别统计出其中英文字母、数字、空格和其他字符的个数。
- 输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数
- 习题 5.4 输入一行字符,分别统计出其中英文字母、空格、数字和其他字符个数。
- oj第九周练习 统计出其中英文字母、数字、空格和其他字符的个数