POJ 2136 Vertical Histogram

Source: Internet
Author: User

POJ 2136 Vertical Histogram

Analysis: A long time ago, I encountered this question in K & R, but it was a little more complicated than this question ....

It's also a water question. There's nothing to say. Pay attention to the details, such as the output format. In addition, the for loop is used at the beginning and printed directly after each input line ends, depressing ^ ~ _~ ^

 

 

Description

Write a program to read four lines of upper case (I. e ., all capital letters) text input (no more than 72 characters per line) from the input file and print a vertical histogram that shows how many times each letter (but not blks, digits, or punctuation) 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 72 characters per line.

Output

* Lines 1 ..?? : Several lines with asterisks and spaces followed by one line with the upper-case alphabet separated by spaces. do not print unneeded blanks at the end of any line. do not print any leading blank lines.

Sample Input

THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG.THIS IS AN EXAMPLE TO TEST FOR YOURHISTOGRAM PROGRAM.HELLO!

Sample Output

                            *                            *        *                   *        *                   *     *   *        *                   *     *   **       *     *             *     *   **       *     * *     * *   *     * * **       *   * * *     * *   * *   * * * **     * * * * * *     * * * * *   * * * *     * ** * * * * * * * * * * * * * * * * * * * * * * * * *A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 

 

 

#include 
 
  #include 
  
   #include 
   
    #include 
    
     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
     
      =65 && s[i]<=90)++c[s[i]-'A'];}for(i=0;i<26;i++)if(maxhigh
      
       0;i--){for(j=0;j<26;j++)if(c[j]>=i)printf("* ");elseprintf(" ");printf("\n");}for(i=0;i<26;i++){if(i>0)printf(" ");printf("%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 72 characters per line) from the input file and print a vertical histogram that shows how many times each letter (but not blks, digits, or punctuation) 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 72 characters per line.

Output

* Lines 1 ..?? : Several lines with asterisks and spaces followed by one line with the upper-case alphabet separated by spaces. do not print unneeded blanks at the end of any line. do not print any leading blank lines.

Sample Input

THE QUICK BROWN FOX JUMPED OVER THE LAZY DOG.THIS IS AN EXAMPLE TO TEST FOR YOURHISTOGRAM PROGRAM.HELLO!

Sample Output

                            *                            *        *                   *        *                   *     *   *        *                   *     *   **       *     *             *     *   **       *     * *     * *   *     * * **       *   * * *     * *   * *   * * * **     * * * * * *     * * * * *   * * * *     * ** * * * * * * * * * * * * * * * * * * * * * * * * *A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.