Analysis: a long time ago, in the "K&r" above this problem, just a little more complicated than this ....
is also a water problem, nothing to say, pay attention to details, such as the format of the output, there is, the first for the loop, each input line after the end of direct printing, good depressed ^ ~_~ ^
Description
Write a program to read four lines of upper case (i.e., all capital LETTERS) text input (no more than characters per Li NE) from the input file and print a vertical histogram This shows how many times each letter (but not blanks, digits, or P Unctuation) appears in the All-upper-case input. Format your output exactly as shown.
Input
* Lines 1..4:four Lines of upper case text, no more than-characters per line.
Output
* Lines 1 ...??: Several Lines with asterisks and spaces followed by one line with the upper-case alphabet separated by Spac Es. Do not print unneeded blanks at the end of any line. Don't print any leading blank lines.
Sample Input
The QUICK BROWN FOX JUMPED over the LAZY DOG. This is a EXAMPLE to TEST for Yourhistogram program. Hello!
Sample Output
* * * * * * * * * * * ** * * * * ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *a B C D E F G H I J K L M
#include <iostream> #include <cstdio> #include <cstring> #include <string>using namespace std; int main () {int len,i,j,maxhigh=0;string s;int c[26];memset (c,0,sizeof (c)), while (Cin>>s) {len=s.length (); for (i =0;i<len;i++) if (s[i]>=65 && s[i]<=90) ++c[s[i]-' A '];} for (i=0;i<26;i++) if (Maxhigh<c[i]) maxhigh=c[i];for (i=maxhigh;i>0;i--) {for (j=0;j<26;j++) if (c[j]>= i) printf ("*"), elseprintf (" ");p rintf ("\ n");} for (i=0;i<26;i++) {if (i>0) printf ("");p rintf ("%c", i+ ' A ');} printf ("\ n"); return 0;}
Description
Write a program to read four lines of upper case (i.e., all capital LETTERS) text input (no more than characters per Li NE) from the input file and print a vertical histogram This shows how many times each letter (but not blanks, digits, or P Unctuation) appears in the All-upper-case input. Format your output exactly as shown.
Input
* Lines 1..4:four Lines of upper case text, no more than-characters per line.
Output
* Lines 1 ...??: Several Lines with asterisks and spaces followed by one line with the upper-case alphabet separated by Spac Es. Do not print unneeded blanks at the end of any line. Don't print any leading blank lines.
Sample Input
The QUICK BROWN FOX JUMPED over the LAZY DOG. This is a EXAMPLE to TEST for Yourhistogram program. Hello!
Sample Output
* * * * * * * * * * * ** * * * * ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *a B C D E F G H I J K L M
POJ 2136 Vertical Histogram