Zju 2726 Constellation 解题分析与测试输出

终于把Zju 2726搞定了,哈哈哈!!!

本题的主要注意点是题目中的Notice。

Notice: the histogram should show out the exact proportions, however, the height of each bar should be as short as possible (see the samples).

例如有10个人,两个星座,人数分别为6,4,则XX长度应为3,2。即要约去各个人数的最大公约数。

另外注意,每行末不能有多余的空格。这个可以先把每行要输出的内容放到一个串中,然后去除尾部空格后再输出。

练习STL的string,stringstream,vector等容器的好习题。可以看看下面的Sample Input和Sample Output。

Sample Input:

1

March 19

12

March 19

March 20

March 20

March 19

March 19

March 19

October 22

October 22

October 22

October 22

October 22

October 22

11

March 19

March 20

March 20

March 19

March 19

October 22

October 22

October 22

October 22

October 22

October 22

5

March 20

March 20

March 20

October 22

October 22

0
Sample Output:

                                              1

                                             XX

------------------------------------------------

 Ar  Ta  Ge  Ca  Le  Vi  Li  Sc  Sa  Ca  Aq  Pi



                          6

                         XX                   4

  2                      XX                  XX

 XX                      XX                  XX

------------------------------------------------

 Ar  Ta  Ge  Ca  Le  Vi  Li  Sc  Sa  Ca  Aq  Pi



                          6

                         XX

                         XX

                         XX                   3

  2                      XX                  XX

 XX                      XX                  XX

 XX                      XX                  XX

------------------------------------------------

 Ar  Ta  Ge  Ca  Le  Vi  Li  Sc  Sa  Ca  Aq  Pi



  3

 XX                       2

 XX                      XX

 XX                      XX

------------------------------------------------

 Ar  Ta  Ge  Ca  Le  Vi  Li  Sc  Sa  Ca  Aq  Pi



阅读更多

Constellation

04-06

The constellation is very popular today. Many people believe that people with different constellations have different characters. Vivid asks you to help him calculate the distribution of constellations in his class.nnYou are given the birthdays of Vivid's classmates. Your program should print out a histogram to show the distribution of constellations.nnThe corresponding relationship between the constellations and the dates are listed below:nAries - March 20th to April 20thnTaurus - April 21st to May 21stnGemini - May 22nd to June 22ndnCancer - June 23rd to July 22ndnLeo - July 23rd to August 22ndnVirgo - August 23rd to September 22ndnLibra - September 23rd to October 22ndnScorpion - October 23rd to November 22ndnSagitarius - November 23rd to December 22ndnCapricorn - December 23rd to January 21stnAquarius - January 22nd to February 20thnPisces - February 21st to March 19thnnNotice: the histogram should show out the exact proportions, however, the height of each bar should be as short as possible (see the samples).nnInput:nnThere are multiple test cases. Each test case begins with an integer N (the number of Vivid's classmates, 1 <= N <= 50), followed by N lines of strings indicating the birthdays of them. A birthday is represented by the month (an English word), a blank, and the date. You can assume all the birthdays are valid dates. A case with N = 0 indicates the end of input. Do not proceed this case.nnOutput:nnFor each test case, print the histogram to show the constellation distribution. See the sample outputs for directions. No trailing space is allowed. A blank line should be printed after each test case.nnSample Input:n4nMarch 19nMarch 20nMarch 19nMarch 20n19nMarch 19nMarch 20nMarch 20nMarch 19nMarch 19nMarch 20nMarch 20nMarch 19nMarch 19nMarch 20nMarch 20nMarch 19nMarch 19nMarch 20nMarch 20nMarch 19nMarch 19nMarch 20nMarch 20n0nSample Output:n 2 2n XX XXn------------------------------------------------n Ar Ta Ge Ca Le Vi Li Sc Sa Ca Aq Pinn 10n XX 9n XX XXn XX XXn XX XXn XX XXn XX XXn XX XXn XX XXn XX XXn XX XXn------------------------------------------------n Ar Ta Ge Ca Le Vi Li Sc Sa Ca Aq Pi

没有更多推荐了,返回首页