Let the Balloon risetime limit:2000/1000ms (java/other) Memory limit:65536/32768k (Java/other) total submission (s) : Accepted Submission (s): 6Font:Times New Roman|Verdana|GeorgiaFont Size:← →Problem Descriptioncontest Time again! How excited it was to see balloons floating around. But to tell you a secret, the judges ' favorite time was guessing the most popular problem. When the contest was over, they would count the balloons of each color and find the result.
This is the year that they decide to leave the lovely job to you.
Inputinput contains multiple test cases. Each test case is starts with a number n (0 < N <=) – The total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to lower-case letters.
A test Case with N = 0 terminates the-input and this-test case are not-to-be processed.
Outputfor each case, print the color of balloon for the most popular problem to a single line. It is guaranteed this there is a unique solution for each test case.
Sample Input
5greenredblueredred3pinkorangepink0
Sample Output
Redpink
#include <iostream> #include <string> #include <stdio.h> #include <map>using namespace Std;int Main () {map<string,int> m;//map<string,int>::iterator it;int max;string s;int n;int i,j;while (scanf ("%d", &n), N) {max=-1;for (i=0;i<n;i++) {cin>>s;m[s]++;} For (Map<string,int>::iterator It=m.begin (); It!=m.end (); it++) if ((*it). Second>max) {s= (*it). First; Max= (*it). Second;} Cout<<s<<endl;m.clear ();} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Let the Balloon Rise