描述
数据
评测
题目描述
输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
输入描述
输出描述
样例输入
a 1,
样例输出
1 1 1 1
#include<stdio.h>
int main ()
{ int letter,k,digit,other;
letter=k=digit=other=0;
char ch;
while((ch=getchar())!='\n') //关键在于终止条件=-= 当输入换行时结束
{
if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
letter++;
else if(ch==' ')
k++;
else if(ch>='0'&&ch<='9')
digit++;
else
other++;
}
printf("%d\n",letter);
printf("%d\n",k);
printf("%d\n",digit);
printf("%d\n",other);
return 0;
}