#include <stdio.h>
int main()
{
char c;
int letter = 0, space = 0, digit = 0, other = 0;
printf("input a char line:");
c = getchar();
while (c != '\n')
{
if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
letter++;
else if (c >= '0' && c <= '9')
digit++;
else if (c == ' ')
space++;
else
other++;
c = getchar();
}
printf("letter=%d digit=%d space=%d other=%d",letter,digit,space,other);
return 0;
}
标签:字符,digit,&&,space,++,个数,空格,other,letter From: https://blog.51cto.com/u_16336886/8306375