Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 87647    Accepted Submission(s): 33130

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
想了好久,决定用链表了
#include <iostream>
using namespace std;
const int Max=1100;
struct node
{
string s;
int num;
node *next; };
int main()
{
int n;
string str;
while(cin>>n,n)
{
node *head,*p,*q;
head=new node;
head->next=NULL;
for(int i=0; i<n; i++)
{
cin>>str;
q=head;
p=head->next;
while(p)
{
if(p->s==str)
{
p->num++;
break;
}
p=p->next;
q=q->next;
}
if(!p)
{
p=new node;
p->s=str;
p->num=1;
p->next=NULL;
q->next=p;
}
}
p=head->next;
q=head->next;
while(p)
{
if(p->num>q->num)
{
q=p;
}
p=p->next;
}
cout<<q->s<<endl; }
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏的更多相关文章

  1. Hdu 1010 Tempter of the Bone 分类: Translation Mode 2014-08-04 16:11 82人阅读 评论(0) 收藏

    Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Othe ...

  2. makefile基础实例讲解 分类: C/C++ 2015-03-16 10:11 66人阅读 评论(0) 收藏

    一.makefile简介 定义:makefile定义了软件开发过程中,项目工程编译链.接接的方法和规则. 产生:由IDE自动生成或者开发者手动书写. 作用:Unix(MAC OS.Solars)和Li ...

  3. SQL 存储过程 分页 分类: SQL Server 2014-05-16 15:11 449人阅读 评论(0) 收藏

    set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go -- ============================================= -- Au ...

  4. leetcode N-Queens/N-Queens II, backtracking, hdu 2553 count N-Queens, dfs 分类: leetcode hdoj 2015-07-09 02:07 102人阅读 评论(0) 收藏

    for the backtracking part, thanks to the video of stanford cs106b lecture 10 by Julie Zelenski for t ...

  5. hdu 1053 (huffman coding, greedy algorithm, std::partition, std::priority_queue ) 分类: hdoj 2015-06-18 19:11 22人阅读 评论(0) 收藏

    huffman coding, greedy algorithm. std::priority_queue, std::partition, when i use the three commente ...

  6. Hdu 1507 Uncle Tom's Inherited Land* 分类: Brush Mode 2014-07-30 09:28 112人阅读 评论(0) 收藏

    Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (J ...

  7. Hdu 1429 胜利大逃亡(续) 分类: Brush Mode 2014-08-07 17:01 92人阅读 评论(0) 收藏

    胜利大逃亡(续) Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Subm ...

  8. Hdu 1009 FatMouse' Trade 分类: Translation Mode 2014-08-04 14:07 74人阅读 评论(0) 收藏

    FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. HDU 1532 Drainage Ditches 分类: Brush Mode 2014-07-31 10:38 82人阅读 评论(0) 收藏

    Drainage Ditches Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

随机推荐

  1. 【转】Tomcat组件生命周期管理

    Tomcat组件生命周期管理 Tomcat中Server,Service,Connector,Engine,Host,Context,它们都实现了org.apache.catalina.Lifecyc ...

  2. c#:拖动功能

    需求:放在图层上一个图片,要实现鼠标可以选中,并实现拖放功能. 需求分析: 1.采用winform方式实现: 2.需要一个PictureBox对象,对该PictureBox添加MouseMove,Mo ...

  3. CSS位置如何获取的

  4. Debug 介绍

    Debug 设置

  5. Java数组(初学者必看)

    数组无论在哪种编程语言中都算是最重要的数据结构之一,同时不同语言的实现及处理也不尽相同.但凡写过一些程序的人都知道数组的价值及理解数组的重要性,与链表一道,数组成为了基本的数据结构.尽管Java提供了 ...

  6. 当As3遇见Swift(三)

    类 As3 Swift中似乎没有包,包路径的概念.因而显得简洁的多. package { public class ShuaiGe { } } Swift类 class ShuaiGe{ } 类的构造 ...

  7. Activity之间的数据传递

    最常用的Activity之间的数据传递. btnStartAty1.setOnClickListener(new View.OnClickListener() { @Override public v ...

  8. eclipse 导入jdbc4.jar 包

    详细讲解链接 http://wenku.baidu.com/link?url=QUhO2rIL2fYRgOUyd1TQPEgbl0jQr156ioxK5fiwSPm_Tset2okpBEJcO1fmz ...

  9. PHP和JS实现多按钮提交表单

    JS: <html> <head> <script> function submitit1() //交由程序1处理 { document.myForm.action ...

  10. RMQ求区间最值 nlog(n)

    转载于:http://blog.csdn.net/xuzengqiang/article/details/7350465 RMQ算法全称为(Range Minimum/Maximum Query)意思 ...