hdu 1004 Let the Balloon Rise map的应用
题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1004
map的用法,第一次看见map还能这么用
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<iostream> #include<map> #include<string> using namespace std; int n; string s; int main() { while (cin >> n, n){ map<string, int>a; map<string, int>::iterator b; for (int i = 0; i < n; i++){ cin >> s; a[s]++; } b = a.begin(); int ans=0; string res; for (; b != a.end(); b++){ if (b->second >ans){ ans = b->second; res = b->first; } } cout << res << endl; } return 0; }