Description
输入一行字符,分别统计出其中英文字母、数字、空格和其他字符的个数。
Input
一行字符
Output
统计值
Sample Input
aklsjflj123 sadf918u324 asdf91u32oasdf/.’;123
Sample Output
23 16 2 4
#include<stdio.h>
int main(){
char ch;
int en = 0;
int num = 0;
int space = 0;
int others = 0;
while((ch = getchar()) != '\n'){
if(ch <= '9' && ch >= '0')
num++;
else if((ch >= 65 && ch <= 90)||(ch >= 97 && ch <= 122))
en++;
else if(ch == ' ')
space++;
else
others++;
}
printf("%d %d %d %d \n",en,num,space,others);
return 0;
}