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]