Problem Description
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.

 
Input
Input 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.

 
Output
For 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
 
使用C++ STL中的map模板
#include<iostream>
#include<cstdio>
#include<map>
#include<string>
#include<cstring>
using namespace std; void solve()
{
int T, max, t;
map<string, int> color_count;
string color;
while(cin>>T && T) {
max = ;
while(T--) {
cin>>color;
++color_count[color];
}
map<string, int>::const_iterator ii, it;
it = color_count.begin();
while(it != color_count.end()) {
if(max < it->second) {
max = it->second;
ii = it;
}
it++;
}
cout<<ii->first<<endl;
color_count.clear();
}
} int main()
{
solve();
return ;
}

最新文章

  1. java中面向对象的一些知识(一)
  2. MySQL 笔记2
  3. goldengate studio 12.2.1.2.6发布
  4. CSS中的margin、border、padding区别
  5. x86虚拟地址到物理地址的映射学习
  6. 【剑指Offer学习】【面试题55:字符流中第一个不反复的字符】
  7. 关于fork函数
  8. java中线程机制
  9. 8.5 sikuli 集成进eclipse 报错:can&#39;t be found on the disk
  10. 【项目记录】-路灯监测 gmap.net
  11. angular的小实例
  12. git diff 结果分析
  13. KALI安装与环境配置
  14. concurrent.future
  15. RabbitMQ中各种消息类型如何处理?
  16. python之socket运用2
  17. PyQt4 Box布局
  18. 机器学习实战python3 Logistic Regression
  19. 枚举子集&amp;高位前缀和
  20. JNI 里使用STL

热门文章

  1. 【BZOJ2648】SJY摆棋子 KDtree
  2. Online Judge(字符串-格式)
  3. RTSP安防摄像机(海康大华宇视等)如何推送到RTMP流媒体服务器进行直播
  4. java图片二进制相互转换
  5. 《挑战程序设计竞赛》2.2 贪心法-区间 POJ2376 POJ1328 POJ3190
  6. Introduction to Mathematical Thinking - Week 6 - Proofs with Quantifieers
  7. Echarts-雷达图
  8. curl学习总结
  9. python多线程安全local()
  10. ExtJS4 给同一个formpanel不同的url