Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.

This year, they decide to leave this lovely job to you.

InputInput contains multiple test cases. Each test case starts
with a number N (0 < N <= 1000) -- the total number of balloons
distributed. The next N lines contain one color each. The color of a
balloon is a string of up to 15 lower-case letters.

A test case with N = 0 terminates the input and this test case is not to be processed.

OutputFor each case, print the color of balloon for the most
popular problem on a single line. It is guaranteed that there is a
unique solution for each test case.

Sample Input

5
green
red
blue
red
red
3
pink
orange
pink
0

Sample Output

red
pink 代码:
#include <iostream>
#include <cstdio>
#include <queue>
#include <map>
using namespace std; int main()
{
int n;
string a,max="a";
map<string,int> b;
while(scanf("%d",&n)&&n)
{
b[max]=;
for(int i=;i<=n;i++)
{
cin>>a;
b[a]++;
if(b[a]>b[max])max=a;
}
cout<<max<<endl;
}
}

最新文章

  1. Leetcode N-Queens II
  2. 计算NSString含有多少个相同字符串
  3. xmpp4-总览
  4. BootstrapDialog自动加&lt;br&gt; BUG处理
  5. java培训(5-8节课)
  6. Eclipse如何生成带有自定tag的Java Doc
  7. 高频(工作频率为13.56MHz)
  8. Android 动画具体解释View动画
  9. node.js实现简单的登录注册页面
  10. HTTP协议类
  11. PHP 公共方法分享180628
  12. 短路运算符(逻辑与&amp;&amp; 和 逻辑或||)
  13. java线程池和中断总结
  14. 利用matplotlib的plot函数实现图像绘制
  15. IPutils
  16. Qracle 11g 插图安装
  17. 深入理解java集合框架之---------Linked集合 -----构造函数
  18. scrapy抓取拉勾网职位信息(六)——反爬应对(随机UA,随机代理)
  19. 网页入口ControlServlet分析
  20. ps命令 百度+加自己的理解

热门文章

  1. WPF 的 数据源属性 和 数据源
  2. arcgis for silverlight 地图放大到某个点或者几何对象
  3. 20170801xlVBA含有公式出现弹窗合并
  4. 《图解Http》8: 用户身份认证Cookie管理session; 9:HTTP的追加协议(websoket, webDAV)
  5. Razor及HtmlHelper学习笔记
  6. [HEOI2012]采花
  7. CoderForce 148D-Bag of mice (概率DP求概率)
  8. Oracle11g温习-第九章:表空间和数据文件管理
  9. fabric 学习笔记
  10. spring boot 学习(六)spring boot 各版本中使用 log4j2 记录日志