#include<stdio.h>
void main()
{
char c;
int letter = 0, space = 0, digit = 0, other = 0;
printf("请输入需要统计的字段:\n");
while ((c = getchar()) != '\n')//运用getchar逐个识别,回车结束
{
if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
letter++;
else if (c == ' ')
space++;
else if (c >= '0' && c <= '9')
digit++;
else
other++;
}
printf("letter=%d\nspace=%d\ndigit=%d\nother=%d", letter, space, digit, other);
}