首页 > 其他 > 详细

hdu 1004 Let the Balloon Rise 解题报告

时间:2014-04-16 06:30:05      阅读:337      评论:0      收藏:0      [点我收藏+]

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004

    用STL 中的 Map 写的

    

bubuko.com,布布扣
 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstdlib>
 4 #include <cstring>
 5 #include <string>
 6 #include <map>
 7 using namespace std;
 8 
 9 map<string, int> ballon;
10 string tmp;
11 
12 int main()
13 {
14     int i, j, n;
15     while (cin >> n && n)
16     {
17         ballon.clear();
18         for (i = 0; i < n; i++)
19         {
20             cin >> tmp;
21             ballon[tmp]++;
22         }
23         map<string, int>::iterator iter, poi;
24         int maxp = 0;
25         for (iter = ballon.begin(); iter != ballon.end(); iter++)
26         {
27             if (maxp < iter->second)
28             {
29                 maxp = iter->second;
30                 poi = iter;
31             }
32         //    cout << iter->first << "  " << iter->second << endl;
33         }
34         cout << poi->first << endl;
35     }
36     return 0;
37 
38 }
bubuko.com,布布扣

 

hdu 1004 Let the Balloon Rise 解题报告,布布扣,bubuko.com

hdu 1004 Let the Balloon Rise 解题报告

原文:http://www.cnblogs.com/windysai/p/3667242.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!