mirror of
https://github.com/renbaoshuo/202401-programming-assignments.git
synced 2024-12-16 15:44:39 +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;
|
|
}
|