#include<stdio.h>
int main(void)
{
/*********Begin*********/
char c;
int i, j, count1=0, count2=0, count3=0,count4=0;
i = 0;
while ((c = getchar())!='\n')
{
if (c>= 'A' && c<= 'z' && c>= 'a' &&c <= 'z')
{
count1++;
}
else if (c >= '0' && c <= '9')
{
count2++;
}
else if (c == ' ')
{
count3++;
}
else
count4++;
}
printf("%d %d %d %d", count1, count2, count3, count4);
/*********End**********/
return 0;
}
while语句中加入getchar接受字符,‘n’判断是否读取字符串完毕
条件语句再分别将数字加起来