您的位置:首页 > 其它

统计出其中英文字母、数字、空格和其他字符的个数

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;
}

输出结果:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐