hdu1004Let the Balloon Rise

来源:互联网 发布:mac怎么把图标放到桌面 编辑:程序博客网 时间:2024/04/27 17:05
#include <iostream>#include <cstdio>#include <cstring>#include <map>#include <algorithm>using namespace std;//2013-08-31 15:48:21Accepted10040MS372K956 BG++Achiberxint main(){    int n;    string t;    map<string, int> mymap;    map<string, int>::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;}/**5greenredblueredred3pinkorangepink0**/
原创粉丝点击