HDOJ 1004

HDOJ1004 Let the Balloon Rise

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//
// main.cpp
// largeNumberSort
//
// Created by richard on 9/9/15.
// Copyright (c) 2015 luxin. All rights reserved.
//
#include <iostream>
#include <map>
#include <string>

using namespace std;



int main(){

// freopen("/Users/RichardLu/Code/C++/Algorithm/largeNumberSort/largeNumberSort/largeNumberSort/testcase.in", "r", stdin);
// freopen("/Users/RichardLu/Code/C++/Algorithm/largeNumberSort/largeNumberSort/largeNumberSort/testcase.out", "w", stdout);


map<string, int> string_int_map;
string a;
int count = 0;
while (cin >> count&&count) {
string_int_map.clear();
while (count--) {
cin >> a;
string_int_map[a]++;
}

string most = "";
for (map<string, int>::iterator it = string_int_map.begin(); it != string_int_map.end(); ++it) {
if (it->second > string_int_map[most]) {
most = it->first;
}
}
cout <<most<<endl;
}

// fclose(stdin);
// fclose(stdout);

return 0;
}