hdu 1004.Let the Balloon Rise

#include <iostream>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
map<string,int> color;


int main()
{
    int n,max;
    string str;
    map<string,int>::iterator iter;
    while(cin>>n&&n)
    {
        color.clear();
        max=0;
        while(n--)
        {
            cin>>str;
            ++color[str];
        }
        iter=color.begin();
        while(iter!=color.end())
        {


            max=max>iter->second?max:iter->second;
            iter++;
        }
        cout<<str<<endl;
        iter=color.begin();
        while(iter!=color.end())
        {
            if(iter->second==max)
            {
                cout<<iter->first<<endl;
                break;
            }
            else
                iter++;
        }
    }
    return 0;
}

你可能感兴趣的:(String,iterator,include)