1 /* Write a program to print a histogram of the frequencies of
2 * different characters in its input. */
9 int histogram[CHARSIZE], c, maxfreq;
11 for (int i = 0; i < CHARSIZE; ++i)
16 while ((c = getchar()) != EOF) {
19 for (int i = '0'; i <= '9'; ++i) {
20 printf("%c: %6d\n", i, histogram[i]);
22 for (int i = 'A'; i <= 'Z'; ++i) {
23 printf("%c: %6d\n", i, histogram[i]);
25 for (int i = 'a'; i <= 'z'; ++i) {
26 printf("%c: %6d\n", i, histogram[i]);
31 for (int i = 1; i <= MAXLENGTH; ++i) {
32 printf("%2d: %5d", i, histogram[i]);
33 for (int j = 0; j < histogram[i]; ++j) {
38 maxfreq = (histogram[i] > maxfreq ? histogram[i] : maxfreq);
41 for (int h = maxfreq; h > 0; --h) {
42 for (int i = 1; i <= MAXLENGTH; ++i) {
43 if (histogram[i] >= h) {
51 for (int i = 1; i <= MAXLENGTH; ++i) {
55 for (int i = 1; i <= MAXLENGTH; ++i) {