`
googlelc
  • 浏览: 55363 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

hdoj1004

 
阅读更多
 #include<iostream>
using namespace std;
#include<string>
#include<map> 
int main()
{
  int n,i;
  map<string,int> ball;
  while( cin >> n)
  {
        if(n==0)break;
        ball.clear();
        string color,pcolor;
        for( i = 0;i<n;i ++)
        {
             cin >> color;
             if(ball.count(color)==0)
             {
                  ball.insert(pair<string,int>(color,1));                   
                                     }
              else 
              {
                   ball[color]++;
                   }                       
             }
           map<string,int>::iterator it;
           int count = -1;
           for( it=ball.begin();it!=ball.end();it++)
           {
                if((*it).second>count)
                {
                count = (*it).second;
                pcolor = (*it).first;
                                      }
                } 
             cout << pcolor << endl;    
         }
    system("pause");
    } 


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics