#include<stdio.h>
int main() {
char c;
int letter=0, number=0, space=0, other=0;
c = getchar();
while (c!='\n') {
if ((c >= 'a' && c <= 'z') || (c >= 'A') && c <= 'Z') {
letter++;
}
else if(c >= '0' && c <= '9') {
number++;
}
else if (c == ' ') {
space++;
}
else {
other++;
}
c = getchar();
}
printf("字母=%d,数字=%d,空格=%d,其他=%d",letter,number,space,other);
return 0;
}
C语言——统计输入的字母数字空格以及其他字符的个数
于 2023-11-04 15:07:57 首次发布