hdu1004Let the Balloon Rise

2014-11-23 21:38:23 · 作者: · 浏览: 7
#include 
#include 
#include 
#include 
#include 

using namespace std;
//	2013-08-31 15:48:21	Accepted	1004	0MS	372K	956 B	G++	Achiberx
int main()
{
    int n;
    string t;
    map mymap;
    map::iterator it;
    while(scanf("%d", &n) != EOF && n) {
        mymap.clear();
        for(int i = 0; i < n; i++) {
            cin >> t;
            it = mymap.find(t);
            if(it != mymap.end()) {
                it->
second ++; } else { mymap[t] = 1; // printf("%d\n", mymap[t]); } } string res; int maxv = 0; for(it = mymap.begin(); it != mymap.end(); ++it) { if(it->second > maxv) { maxv = it->second; res = it->first; } } cout << res << endl; } return 0; } /** 5 green red blue red red 3 pink orange pink 0 **/