hdu 1004 let the balloon rise

https://vjudge.net/problem/HDU-1004

题意:

找出最受欢迎的气球的颜色。

思路:

真水题啊,居然是字典树的例题,然后还是用map坚决水过去了O(∩_∩)O

代码:

 1 #include <string>
 2 #include <stdio.h>
 3 #include <iostream>
 4 #include <map>
 5 using namespace std;
 6 
 7 map<string,int> mmp;
 8 
 9 int main()
10 {
11     int n;
12 
13     while (scanf("%d",&n) != EOF && n)
14     {
15         string ans;
16 
17         int maxn = 0;
18 
19         mmp.clear();
20 
21         for (int i = 0;i < n;i++)
22         {
23             string t;
24 
25             cin >> t;
26 
27             mmp[t]++;
28 
29             if (mmp[t] > maxn)
30             {
31                 maxn = mmp[t];
32 
33                 ans = t;
34             }
35         }
36 
37         cout << ans << endl;
38     }
39 
40 
41     return 0;
42 }
原文地址:https://www.cnblogs.com/kickit/p/7241901.html