【问题描述】输入一行字符,统计出其中的英文字母、空格、数字和其他字符的个数。
【样例输入】Hello world 123!
【样例输出】blank=2,digit=3,letter=10,other=1
#include<stdio.h>
int main()
{
int b,letter = 0, blank = 0,digit = 0,other = 0;
char ch;
ch=getchar();
while(ch!='\n')
{
if (ch >= '0'&&ch <= '9')
digit++;
else if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
letter++;
else if(ch==' ')
blank++;
else other++;
ch=getchar();
}
printf("blank=%d,digit=%d,letter=%d,other=%d",blank,digit,letter,other);
return 0;
}