blob: ae885213fb48ea90afa9e1552bbe9fe7fe1f750f (
plain) (
tree)
|
|
#include <stdio.h>
#define OUTWORD 0
#define INWORD 1
#define MAXWORDLEN 20
int main () {
int c, i, wordlen;
int ndigit[MAXWORDLEN] = {0};
wordlen = 0;
char state = OUTWORD;
while ((c = getchar()) != EOF) {
if (c == ' ' || c == '\n' || c == '\t') {
if (state == INWORD) ++ndigit[wordlen];
wordlen = 0;
state = OUTWORD;
}
else {
state = INWORD;
++wordlen;
}
}
for (i = 0; i < MAXWORDLEN; ++i) {
printf("%2d | ", i);
for (int j = 0; j < ndigit[i]; ++j)
printf("=");
printf("%d\n", ndigit[i]);
}
}
|