#include<stdio.h>
int max = 0;
int count(int letter[26]) {
int word = 0;
char ch, pre; // pre 表示前一个字母
while ((ch = getchar()) != EOF) { //默认首个输入非空白
if (ch != ' ' && ch != '\n') { // 不可写成(ch != ' ' && '\n')
++letter[ch - 97]; //因为!= 优先级 高于 && 相当于(ch != ' ' )&& '\n'
if (max < letter[ch - 97]) // 会导致 ch == '\n' 时测试语句为真
max = letter[ch - 97];
// if (ch == '\n')
// printf("oo\n");
}
else {
/* if (ch == '\n')
printf("hey\n");
else if (ch == ' ')
printf("haha\n");
*/ if (pre >= 97 && pre <= 122) //假设以EOF结尾, 要加上一个Word
++word;
}
pre = ch;
}
// printf("%d\n", ch);
if (pre >= 97 && pre <= 122)
++word;
return word;
}
void Printf(int letter[26], int word) {
int i, j;
max = (max > word) ? max : word;
for (i = max; i > 0; --i) {
printf("%d\t", i);
for (j = 0; j < 26; ++j) {
if (letter[j] == 0)
continue;
else if (letter[j] >= i)
printf("*");
else
printf(" ");
}
if (word >= i)
printf("*");
else
printf(" ");
printf("\n");
}
printf(" \t");
for (i = 0; i < 26; ++i) {
if (letter[i] == 0)
continue;
else
printf("%c", 'a' + i);
}
printf("W");
printf("\n");
}
int main(void) {
int letter[26] = {0};
int word;
word = count(letter);
Printf(letter, word);
return 0;
}