字符处理 HDU-1004
来源:互联网 发布:手机上javaweb编程软件 编辑:程序博客网 时间:2024/06/09 16:52
https://vjudge.net/contest/99636#problem/F
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<stdio.h>#include<string>#include<iostream>#include<map>using namespace std;const int MAXN=1000;int main(){ map<string,int>color; string cnt; string index; int i; int n; int max; while(scanf("%d",&n),n) { max=0; for(i=0;i<n;i++) { cin>>cnt; color[cnt]++; if(color[cnt]>max) { index=cnt;max=color[cnt]; } } cout<<index<<endl; } return 0; }
- 字符处理 HDU-1004
- HDU 2074 叠筐 (字符处理)
- HDU 2700 Parity【字符处理】
- HDU 1228(简单的字符处理)
- hdu-1727-Hastiness(字符处理)
- hdu 1736 美观化文字 中文字符处理
- hdu 2072 单词数 set+按字符处理
- 字符处理
- 字符处理
- 字符处理
- 字符处理
- 字符处理
- 字符处理
- 字符处理
- 字符处理
- HDU 1062.Text Reverse【栈或数组或字符串流】【字符处理】【8月30】
- 指针-字符处理-字符旋转
- hdu 统计字符
- 实时显示鼠标指针相对于浏览器X轴Y轴坐标位置
- 采药
- Hibernate的inverse与cascade
- 使用 SqlBulkCopy大批量插入数据到数据库
- sqlldr导入数据(以PostgreSql>>>Oracle为例)copy call to '/tmp/call.csv' DELIMITER ',' NULL '' CSV
- 字符处理 HDU-1004
- fortify——password Management
- js图片旋转
- 原型模式(ProtoType)
- 【LeetCode】17. Letter Combinations of a Phone Number
- html页面的meta标签的name和http-equiva区别
- 梁广轩_1505010601_实验3
- Android--百度API的初使用
- 静态方法和非静态方法的区别是什么