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

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

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; }

转载地址:http://lmbra.baihongyu.com/

你可能感兴趣的文章
网络诊断工具之—路由追踪tracert命令
查看>>
Java模拟HTTP的Get和Post请求(增强)
查看>>
php 环境搭建(windows php+apache)
查看>>
让虚拟机的软盘盘符不显示(适用于所有windows系统包括Windows Server)
查看>>
Cygwin不好用
查看>>
jQuery插件之验证控件jquery.validate.js
查看>>
[经验]无线鼠标和无线键盘真的不能用了?——雷柏的重生之路~
查看>>
【转】plist涉及到沙盒的一个问题
查看>>
GNU make manual 翻译( 一百四十五)
查看>>
重构之美-走在Web标准化设计的路上[复杂表单]3 9 Update
查看>>
linux中的优先搜索树的实现--prio_tree【转】
查看>>
转载: 打造自己的asp.net验证控件
查看>>
重构之美-跨越Web标准,触碰语义网[开门见山:Microformat]
查看>>
git入门与实践【转】
查看>>
WPF 虚拟键盘
查看>>
储存卡无法打开专家教您怎么数据恢复
查看>>
彼得原理
查看>>
如何利用【百度地图API】,制作房产酒店地图?(下)——结合自己的数据库...
查看>>
[20171113]修改表结构删除列相关问题3.txt
查看>>
特征选择
查看>>