22 lines
496 B
C
22 lines
496 B
C
#include <stdio.h>
|
|
|
|
int main() {
|
|
int ch, n_whitesp, n_other;
|
|
int n_digit[10] = {0}; /* initialize array with zeroes */
|
|
|
|
n_whitesp = n_other = 0;
|
|
|
|
while ((ch = getchar()) != EOF)
|
|
if (ch >= '0' && ch <= '9')
|
|
++n_digit[ch - '0'];
|
|
else if (ch == ' ' || ch == '\n' || ch == '\t')
|
|
++n_whitesp;
|
|
else
|
|
++n_other;
|
|
|
|
printf("digits = ");
|
|
for (int i = 0; i < 10; ++i)
|
|
printf(" %d", n_digit[i]);
|
|
printf(", white space = %d, other = %d\n", n_whitesp, n_other);
|
|
}
|