博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU_1004 Let the Balloon Rise
阅读量:5107 次
发布时间:2019-06-13

本文共 1801 字,大约阅读时间需要 6 分钟。

Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 30537    Accepted Submission(s): 9980
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
 
Author
WU, Jiazhi
 
Source
 
ContractedBlock.gif
ExpandedBlockStart.gif
View Code
#include 
#include
#include
int main() {
char s[1001][16], k[16]; int n, i, j; while(scanf("%d",&n),n) {
for(i = 0; i < n; i++) {
scanf("%s",s[i]); } strcpy(k,s[0]); int sum, max = 0; for(j = 0; j < n-1; j++) {
sum = 0; for(i = j+1; i < n; i++) {
if(strcmp(s[j],s[i]) == 0) sum++; } if(max < sum) {
max = sum; strcpy(k,s[j]); } } puts(k); } return 0; }

转载于:https://www.cnblogs.com/vongang/archive/2011/07/23/2115030.html

你可能感兴趣的文章
小别离
查看>>
微信小程序-发起 HTTPS 请求
查看>>
WPF动画设置1(转)
查看>>
基于node/mongo的App Docker化测试环境搭建
查看>>
秒杀9种排序算法(JavaScript版)
查看>>
Activiti入门 -- 环境搭建和核心API简介
查看>>
struts.convention.classes.reload配置为true,tomcat启动报错
查看>>
MySQL的并行复制多线程复制MTS(Multi-Threaded Slaves)
查看>>
好玩的-记最近玩的几个经典ipad ios游戏
查看>>
PyQt5--EventSender
查看>>
Sql Server 中由数字转换为指定长度的字符串
查看>>
Java 多态 虚方法
查看>>
Unity之fragment shader中如何获得视口空间中的坐标
查看>>
万能的SQLHelper帮助类
查看>>
tmux的简单快捷键
查看>>
[Swift]LeetCode922.按奇偶排序数组 II | Sort Array By Parity II
查看>>
Html5 离线页面缓存
查看>>
《绿色·精简·性感·迷你版》易语言,小到不可想象
查看>>
Android打包key密码丢失找回
查看>>
VC6.0调试技巧(一)(转)
查看>>