hdu1004 (map)

版权声明:《学习技巧》每次使用单边大脑的时间不要太久,连续使用左边大脑30分钟就如同连续使用左臂30分钟一样,周期性的交换让大脑两侧能够轮流休息,左脑活动包括了循序渐进的工作,解决逻辑问题与分析,而右脑活动包括了隐喻,创造性思考,模式匹配和可视化。 https://blog.csdn.net/intmainhhh/article/details/81040220

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

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<string>
#include<map>
using namespace std;

int main(void) {
    map<string,int > ballon;
    string color,Maxcolor;
    int n;
    while(cin>>n && n) {
        ballon.clear();
        for(int i=0; i<n; i++) {
            cin>>color;
            ballon[color]++;
        }
        map<string, int>::iterator it;
        int max = 0;
        for(it=ballon.begin(); it!=ballon.end(); it++) {
            if(it->second>max) {
                max = it->second;
                Maxcolor = it->first;
            }
        }
        cout<<Maxcolor<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/intmainhhh/article/details/81040220