回复 10楼 lz1091914999
不要太黑心,这是交流论坛不是赚钱的!
#include <stdio.h> #define LINE_SIZE 100 // 输入每行小于100个字符 int max(int *array, int size) { int i, max = array[0]; for (i = 1; i < size; ++i) if (max < array[i]) max = array[i]; return max; } void print_line(char *line, int *table) { int i; for (i = 0; i < 26; ++i) if (table['A'+i]) printf("%c ", line ? line[i] : 'A' + i); printf("\n"); } int main(void) { int table[128] = { 0 }, i, j; char paper[4*LINE_SIZE][26], line[LINE_SIZE], *p; for (i = 0; i < 4; ++i) { gets(line); for (p = line; *p; ++p) ++table[(int)*p]; } int rowCount = max(&table['A'], 26); for (i = 0; i < 26; ++i) for (j = 0; j < rowCount; ++j) paper[rowCount-j-1][i] = j < table['A'+i] ? '*' : ' '; for (i = 0; i < rowCount; ++i) print_line(paper[i], table); print_line(0, table); return 0; }