有一个编程题不会编啊
输入一行字符,统计其中英文字母,空格,数字和其他字符的字数。比如输入programming is fun! 就是要输出字母有16个,空格2个,数字0个,其他1个求解求解,求大神解决
程序代码:#include "stdio.h"
void main()
{
char c;
int letters=0,space=0,digit=0,others=0;
printf("please input some characters\n");
while((c=getchar())!='\n')
{
if(c>='a'&&c<='z'||c>='A'&&c<='Z')
letters++;
else if(c==' ')
space++;
else if(c>='0'&&c<='9')
digit++;
else
others++;
}
printf("all in all:char=%d space=%d digit=%d others=%d\n",letters,space,digit,others);
}