2014.1.13 杭电习题 二维字符串中出现数量最多的字符串
来源:互联网 发布:网络推广怎么收费 编辑:程序博客网 时间:2024/06/05 17:09
Let the Balloon Rise
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 15 Accepted Submission(s) : 6
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
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.
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.
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
5greenredblueredred3pinkorangepink0
Sample Output
redpink
Author
Source
ZJCPC2004
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n&&n!=0)
{
char str[1000][100];
int i,j,max=0;
int k=0;
int c[1000]={0};
c[0]=1;
getchar();
for(i=0;i<n;i++)
{
gets(str[i]);
for(j=0;j<i;j++)
if(strcmp(str[i],str[j])==0) //比较两个字符串是否相等
c[j]++;
}
for(i=0;i<n;i++)
if(c[i]>max)
{
max=c[i];
k=i;
}
puts(str[k]);
}
return 0;
}
0 0
- 2014.1.13 杭电习题 二维字符串中出现数量最多的字符串
- 找出字符串中出现次数最多的字符和其出现的数量
- 字符串中出现次数最多的字符
- android获得字符串数组中出现次数最多的字符串
- js判断一个字符串中出现次数最多的字符串
- 出现次数最多的字符串
- ES6的map统计字符串中出现最多的字母
- 找出并统计任意字符串中出现最多的字符
- 选出字符串中出现次数最多的字符
- 字符串中出现次数最多的字符算法
- 取得中文字符串中出现次数最多的子串
- 查找字符串中出现次数最多的字符
- 在字符串中查找出现次数最多的子串
- 统计字符串中出现最多次数的字母
- 求一个字符串中连续出现次数最多的字串
- 找出字符串中连续出现次数最多的子串
- C#取字符串中出现次数最多的字符
- 求一个字符串中连续出现次数最多的字串
- Python画图
- SGU 467 Chessmaster 几何
- Extjs4 Excel导入并在grid显示数据
- 杭电1008 Elevator
- 安卓加速传感器开发
- 2014.1.13 杭电习题 二维字符串中出现数量最多的字符串
- 常用网址资源
- Unable to resolve target 'android-8'
- Extjs4 使用lodop打印控件心得
- phpstorm 快捷键
- 2014.1.13 杭电习题 绝对值排序
- libevent源码分析--event_init()函数
- COM组件开发
- 诚实国度的借道问题用数学模型解