您的位置:首页 > 其它

sicily 1003. 统计各种字符的数量

2014-03-01 23:25 204 查看
Description

输入一行文字,找出大写字母,小写字母,空格,数字以及其他字符的数量

Input

SYSU hello 123 ???
Output

uppercase:4

lowercase:5

number:3

blank:3

others:3



Sample Input
Copy sample input to clipboard

SYSU hello 123 ???


Sample Output

uppercase:4
lowercase:5
number:3
blank:3
others:3


#include<iostream>

#include<cstring>

#include<cstdio>

using namespace std;

char a[101];

int main()

{

gets(a);

int n=strlen(a);

int f=0;

int b=0;

int c=0;

int d=0;

int e=0;

for(int i=0;i<n;i++)

{

if((a[i]<='Z')&&(a[i]>='A')) f++;

if((a[i]<='z')&&(a[i]>='a')) b++;

if(a[i]==' ') c++;

if((a[i]>='0')&&(a[i]<='9')) d++;

else continue;

}

e=n-f-b-c-d;

cout<<"uppercase:"<<f<<endl;

cout<<"lowercase:"<<b<<endl;

cout<<"number:"<<c<<endl;

cout<<"blank:"<<d<<endl;

cout<<"others:"<<e;



return 0;

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