ZOJ_2104_Let the Balloon Rise
来源:互联网 发布:网络市场调研方法 编辑:程序博客网 时间:2024/06/18 17:24
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
map的运用。
代码
#include <iostream>#include <map>using namespace std;int main(){ int n; while(cin>>n&&n) { string s; map<string,int>a; while(n--) { string str; cin>>str; a[str]++; if(a[str]>a[s]) s=str; } cout<<s<<endl; } return 0;}
- ZOJ_2104_Let the Balloon Rise
- ZOJ_2104_Let the Balloon Rise
- Hdu_1004_Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- hdu1004Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- HDOJ1104Let the Balloon Rise
- Let the Balloon Rise
- Let the Balloon Rise
- python正则表达式之一
- 为Eclipse安装CDT插件
- sqlserver数据库和MySQL数据库的连接的一个JUnit测试小记
- 2,3,5,7倍数 (离散(集合))
- 8-5以下面四个标签(读写器范围内)为例说明二进制树型搜索算法选择电子标签迭带过程
- ZOJ_2104_Let the Balloon Rise
- 关于IE8不支持Object.keys()的处理
- 电信141p122第6题
- 关于clean code 的感想
- 物以类聚 – 对象和类
- HDU2846——Repository
- vs 安装不同office引起编译不通过
- Android NDK c创建java对象
- 腾讯校园招聘 涟漪动画的实现