#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");
}
分享到:
相关推荐
hdoj1004,解题代码,答案代码,欢迎下载
ACM ICPC HDOJ1004
Let the Balloon Rise (HDOJ1004) **知识点:** - 字符串处理。 - 字符串匹配算法。 **解题思路:** - 读入字符串。 - 使用循环或字符串函数检查字符串是否包含特定字符序列。 - 如果包含,则输出“YES”,否则...
在ACM竞赛的实践中,我们可以将数学问题分为不同的类别,例如简单的数学问题,像HDOJ1004: Let the Balloon Rise这样的题目,可能涉及基础的算术运算和逻辑推理。通过不断练习和深入学习,参赛者能够提升自己在面对...
杭电OJ(HDOJ)是杭州电子科技大学开发并维护的在线编程竞赛平台,为学习编程、提升算法能力的用户提供了一个实践和竞技的场所。 **二、注册与登录** 1. 注册:首次使用HDOJ的用户需要进行注册,通过填写用户名、...