#include <stdio.h>
#define MAXLETTERCOUNT 26
#define MAXNUMCOUNT 9
int letter[MAXLETTERCOUNT];
int number[MAXNUMCOUNT];
int main(int argc, char **argv) {
char c;
while ((c = getchar()) != EOF) {
if ('A' <= c && c <= 'Z') {
++letter[c - 'A'];
} else if ('a' <= c && c <= 'z') {
++letter[c - 'a'];
} else if ('0' <= c && c <= '9') {
++number[c - '0'];
}
}
for (int i = 0; i < MAXLETTERCOUNT; ++i) {
char startLetter = 'A';
printf("Letter %c: ", startLetter + i);
for (int j = 0; j < letter[i]; ++j) {
printf("*");
}
printf("\n");
}
for (int i = 0; i < MAXNUMCOUNT; ++i) {
char startNumber = '0';
printf("Number %c: ", startNumber + i);
for (int j = 0; j < number[i]; ++j) {
printf("*");
}
printf("\n");
}
printf("\n");
return 0;
}
Test
abcdeaa112345234 df;d
Letter A: ***
Letter B: *
Letter C: *
Letter D: ***
Letter E: *
Letter F: *
Letter G:
Letter H:
Letter I:
Letter J:
Letter K:
Letter L:
Letter M:
Letter N:
Letter O:
Letter P:
Letter Q:
Letter R:
Letter S:
Letter T:
Letter U:
Letter V:
Letter W:
Letter X:
Letter Y:
Letter Z:
Number 0:
Number 1: **
Number 2: **
Number 3: **
Number 4: **
Number 5: *
Number 6:
Number 7:
Number 8: