Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 74110    Accepted Submission(s):
27711

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
 
 
字符串的比较:两个数组color[1005][16]和num[1005]。数组color是用来保存颜色的,数组num是用来保存颜色出现的次数,最后求出数组num中最大的数的下标即为出现次数最多的颜色。
 
 #include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
char color[][];
int num[];
int main()
{
int n, i, j, max;
while(scanf("%d",&n) && n)
{
for (i=; i<n; i++)
scanf("%s",&color[i]);
for(i=; i<; i++)
num[i] = ;
for(i=; i<n; i++)
for(j=; j<i; j++)
if(strcmp(color[i],color[j])==)
num[i]++;
max = ;
j = ;
for(i=; i<n; i++)
if (max<num[i])
{
max = num[i];
j = i;
}
printf("%s\n",color[j]);
}
return ;
}

hdu 1004 Let the Balloon Rise的更多相关文章

  1. hdu 1004 Let the Balloon Rise(字典树)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  2. HDU 1004 Let the Balloon Rise(map的使用)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  3. HDU 1004 Let the Balloon Rise【STL<map>】

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  4. HDU 1004 Let the Balloon Rise map

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  5. hdu 1004 Let the Balloon Rise strcmp、map、trie树

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  6. hdu 1004 Let the Balloon Rise 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 用STL 中的 Map 写的 #include <iostream> #includ ...

  7. HDU 1004 - Let the Balloon Rise(map 用法样例)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  8. HDU 1004 Let the Balloon Rise(map应用)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  9. HDU 1004 Let the Balloon Rise(STL初体验之map)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

随机推荐

  1. SRM 618 DIV1 500

    非常棒的组合问题,看了好一会,无想法.... 有很多做法,我发现不考虑顺序的最好理解,也最好写. 结果一定是两种形式 A....A   dp[n-1] A...A...A sgma(dp[j]*dp[ ...

  2. Tickets——H

    H. Tickets Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this i ...

  3. JavaScript-table+大图滚动

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 害死人不偿命的(3n+1)猜想

    卡拉兹(Callatz)猜想: 对任何一个自然数n,如果它是偶数,那么把它砍掉一半:如果它是奇数,那么把(3n+1)砍掉一半.这样一直反复砍下去,最后一定在某一步得到n=1.卡拉兹在1950年的世界数 ...

  5. hibernate学习(5)——一对多关系表达

    一对多实现 1. 实现类 package com.alice.hibernate02.vo; import java.util.HashSet; import java.util.Set; publi ...

  6. java中return与finally的执行顺序

    可不能小看这个简单的 finally,看似简单的问题背后,却隐藏了无数的玄机.接下来我就带您一步一步的揭开这个 finally 的神秘面纱. 问题分析 首先来问大家一个问题:finally 语句块一定 ...

  7. 关于Unity3D手机网游开发一些小看法

    它的知识技能和职责,我就不仔细说了,说细了有一点像招聘启示.他的主要职责虽然负责技术,但是也给产品决策和方向提供一些决策.他最主要的考核指标,就是经验很重要,最好主导或参与过一款网络游戏的开发.举个例 ...

  8. vert.x学习(六),动态模板与静态文件的结合

    这篇学习在动态模板里面引入css,把动态模板与静态文件结合起来使用. 编写DynamicReference.java package com.javafm.vertx.helloworld; impo ...

  9. Qt程序打包(使用Enigma Virtual Box和BoxedApp Packer封包)

    一.使用单文件封包工具 单文件封包工具,顾名思义就是将可执行文件及其相关依赖打包成单个可执行文件的工具. 这里推荐两个单文件封包工具:Enigma Virtual Box和BoxedApp Packe ...

  10. Java中PreparedStatement与Statement的总结

    概要: PreparedStatement 接口继承自 Statement 接口,PreparedStatement 比普通Statement 对象使用起来更加灵活,更有效率. 一.PreparedS ...