mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-11-27 02:25:37 +00:00
23 lines
557 B
C
23 lines
557 B
C
#include <stdio.h>
|
|
|
|
int main() {
|
|
int sum_alpha = 0, sum_digit = 0, sum_space = 0, sum_other = 0;
|
|
char c;
|
|
|
|
while (scanf("%c", &c) != EOF && c != '\n') {
|
|
if (('A' <= c && c <= 'Z') || ('a' <= c && c <= ' z')) { // isalpha(c)
|
|
sum_alpha++;
|
|
} else if ('0' <= c && c <= '9') { // isdigit(c)
|
|
sum_digit++;
|
|
} else if (c == ' ') {
|
|
sum_space++;
|
|
} else {
|
|
sum_other++;
|
|
}
|
|
}
|
|
|
|
printf("%d %d %d %d\n", sum_alpha, sum_space, sum_digit, sum_other);
|
|
|
|
return 0;
|
|
}
|