Poj 2136 vertical histogram print special graphics

Source: Internet
Author: User

Print the output format as required.

These are some interesting questions. The question itself is not difficult. The difficulty is to test how to program elegantly. It is mainly to test the basic programming skills.

In addition, it seems that the test system is not very strict and does not judge the redundant spaces behind it. According to the requirements of the question, we need to strictly remove the redundant spaces behind it.

To solve this problem, you need more code.

The following shows that I use an extra array spaceheight [alp_len [to solve this problem, so that there is no half of the extra space characters.


# Include <cstdio> # include <string. h> const int max_n = 75; const int alp_len = 26; const int line_n = 4; Short height [alp_len]; short spaceheight [alp_len]; char CHS [max_n]; inline int max (int A, int B) {return A> B? A: B;} inline void getalphacount (char STR []) {int I = 0; while (STR [I]) {If ('A' <= STR [I] & STR [I] <= 'Z') height [STR [I]-'a'] ++; I ++ ;}} int main () {While (gets (CHS) {memset (height, 0, sizeof (height); getalphacount (CHS ); for (INT I = 0; I <LINE_N-1; I ++) {gets (CHS); getalphacount (CHS);} spaceheight [ALP_LEN-1] = height [ALP_LEN-1]; for (INT I = ALP_LEN-2; I> = 0; I --) {spaceheight [I] = max (spaceheight [I + 1], height [I]);} for (int h = spaceheight [0]; h> 0; h --) {for (Int J = 0; j <alp_len; j ++) {If (spaceheight [J] 


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.