Description
输入一行字符,分别统计出其中英文字母、数字、空格和其他字符的个数。
Input
一行字符
Output
统计值
Sample Input ![](image/copy.gif)
aklsjflj123 sadf918u324 asdf91u32oasdf/.';123
Sample Output
23 16 2 4
#include <stdio.h>
#include <ctype.h>
int main()
{
int alpha, digit, space, other;
char c;
alpha = digit = space = other = 0;
while((c = getchar()) != '\n')
{
if(isalpha(c))
alpha++;
else if(isdigit(c))
digit++;
else if(isspace(c))
space++;
else
other++;
}
printf("%d %d %d %d", alpha, digit, space, other);
return 0;
}