设为首页 加入收藏

TOP

hdu1004Let the Balloon Rise
2014-11-23 21:38:23 来源: 作者: 【 】 浏览:6
Tags:hdu1004Let the Balloon Rise
#include 
#include 
#include 
#include 
#include 

using namespace std;
//	2013-08-31 15:48:21	Accepted	1004	0MS	372K	956 B	G++	Achiberx
int main()
{
    int n;
    string t;
    map mymap;
    map::iterator it;
    while(scanf("%d", &n) != EOF && n) {
        mymap.clear();
        for(int i = 0; i < n; i++) {
            cin >> t;
            it = mymap.find(t);
            if(it != mymap.end()) {
                it->second ++;
            }
            else {
                mymap[t] = 1;
               // printf("%d\n", mymap[t]);
            }
        }
        string res;
        int maxv = 0;
        for(it = mymap.begin(); it != mymap.end(); ++it) {
            if(it->second > maxv) {
                maxv = it->second;
                res = it->first;
            }
        }
        cout << res << endl;
    }
    return 0;
}
/**
5
green
red
blue
red
red
3
pink
orange
pink
0
**/

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇[C++基础]关键词volatile 下一篇UVa 567: Risk

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Redis on AWS:Elast (2025-12-27 04:19:30)
·在 Spring Boot 项目 (2025-12-27 04:19:27)
·使用华为开发者空间 (2025-12-27 04:19:24)
·Getting Started wit (2025-12-27 03:49:24)
·Ubuntu 上最好用的中 (2025-12-27 03:49:20)