00001: #include <stdio.h>
00002:
00003: main() /* counts digits, white space, others */
00004: {
00005: int c, i, num_digits[10], num_white, num_other;
00006:
00007: num_white = num_other = 0;
00008:
00009: for(i = 0; i < 10; i++) /* initialize */
00010: num_digits[i] = 0;
00011:
00012: while((c = getchar()) != EOF) {
00013: if (c >= '0' && c <= '9')
00014: ++num_digits[c-'0'];
00015: else if (c == ' ' || c == '\n' || c == '\t')
00016: ++num_white;
00017: else
00018: ++num_other;
00019: }
00020:
00021: printf("digits =");
00022: for(i = 0; i < 10; i++)
00023: printf(" %d", num_digits[i]);
00024: printf(", white space = %d, other = %d\n", num_white, num_other);
00025: }
00026:
|