这不是答案,只是相似程序,仅供参考
#include<stdio.h>
int main()
{
char ch[50];
int i,letter=0,digit=0,blank=0,other=0;
for(i=0;ch[i-1]!='\n';i++)
ch[i]=getchar();
for(i=0;ch[i]!='\n';i++){
if(ch[i]>='A'&&ch[i]<='Z' || ch[i]>='a'&&ch[i]<='z' )
letter++;
else if(ch[i]>='0'&&ch[i]<='9')
digit++;
else if(ch[i]==' ')
blank++;
else
other++;
}
printf("字母:%d,数字:%d,空格:%d,其他:%d\n",letter,digit,blank,other);
return 0;
}