首页 > 其他 > 详细

hdu 1004 Let the Balloon Rise map的应用

时间:2019-03-09 19:15:30      阅读:142      评论:0      收藏:0      [点我收藏+]

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

 

map的用法,第一次看见map还能这么用

技术分享图片
#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;
}
View Code

 

hdu 1004 Let the Balloon Rise map的应用

原文:https://www.cnblogs.com/looeyWei/p/10502507.html

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