解题思路:
注意事项:
前面有一篇类似的帖子
参考代码:
/*输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。*/
#include<stdio.h>
int main()
{
int c, english = 0, space = 0, number = 0, others = 0;
while((c = getchar())!='\n')
{
if(c>='a' && c<='z')
english++;
else if(c == ' ')
space++;
else if(c>='0' && c<='9')
number++;
else
others++;
}
printf("%d\n%d\n%d\n%d\n", english, space, number, others);
return 0;
}
0.0分
0 人评分