Let the Balloon Rise

Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 150   Accepted Submission(s) : 63
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.<br><br>This
year, they decide to leave this lovely job to you. <br>
 
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
 

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
    char str[1001][16];
    int count[1001];
    int n,i,j,index;
    int cnt;
    while(scanf("%d",&n),n){
        index=0;
        char temp[16];
        memset(count,0,sizeof(count));
        while(n--){
            scanf("%s",temp);
            for(j=0;j<index;j++){
                if(strcmp(temp,str[j])==0){
                    count[j]++;
                    break;
                }
            }
            if(j==index){
                memcpy(str[index++],temp,sizeof(temp));
                count[j]++;
            }

        }
        for(i=0,cnt=0;i<index;i++)
                if(count[i]>count[cnt])
                cnt=i;
        printf("%s\n",str[cnt]);

    }
}

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

  1. Let the Balloon Rise HDU水题

    题意 让你统计字符串最多的那个串,并输出 分析 直接用map统计,不断更新最大值即可 代码 #include<iostream> #include<algorithm> #in ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. hdu 1004 Let the Balloon Rise

    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 map

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

  7. 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 ...

  8. Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏

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

  9. HDUOJ Let the Balloon Rise 1004

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

随机推荐

  1. [HCNA]VLAN配置Trunk接口

    实验目的 1.掌握Trunk端口的配置 2.掌握Trunk端口允许所有VLAN通过的配置方法 3.掌握Trunk端口允许特定VLAN通过的配置方法 4.理解干道链路的应用场景 实验仪器 eNSP 实验 ...

  2. 反射 类的加载 Schema DOM 解析方式和解析器 命名空间

    Day15 反射 1.1 类的加载 当程序要使用某个类时,如果该类还未被加载到内存中,则系统会通过加载,连接,初始化三步来实现对这个类进行初始化. l 加载 就是指将class文件读入内存,并为之创建 ...

  3. JAVA 练习 找出素数

    package com.zhang.hello; public class Task { /** * 1. 输出打印九九乘法表 * */ public void NO1(){ for(int i=1; ...

  4. 【已解决】IIS搭建 asp.net core 项目后 其他电脑访问不到资源文件

    IIS搭建asp.net core 项目后,访问不到里面的资源文件(图片等),解决方法如下: 1.检查asp.net core发布文件中的资源文件是不是都放到了wwwroot名称的目录中. 2.检查a ...

  5. MySQL 排序

    MySQL 排序 我们知道从MySQL表中使用SQL SELECT 语句来读取数据. 如果我们需要对读取的数据进行排序,我们就可以使用MySQL的 ORDER BY 子句来设定你想按哪个字段哪中方式来 ...

  6. python OptParse模块的用法详解

    OptParse模块的简单介绍 Python 有两个内建的模块用于处理命令行参数: 一个是 getopt只能简单处理 命令行参数: 另一个是 optparse,它功能强大,而且易于使用,可以方便地生成 ...

  7. vue关于数组使用的坑

    关于数组使用的坑 https://vuejs.org/v2/guide/list.html#Caveats 简言之, 不要使用a[i] = v 的形式, 用a.splice(i, 1, v), 或Vu ...

  8. iOS开源加密相册Agony的实现(七)

    简介 虽然目前市面上有一些不错的加密相册App,但不是内置广告,就是对上传的张数有所限制.本文介绍了一个加密相册的制作过程,该加密相册将包括多密码(输入不同的密码即可访问不同的空间,可掩人耳目).Wi ...

  9. Activtiy完全解析(二、layout的inflate过程)

    转载请标明出处: http://blog.csdn.net/xmxkf/article/details/52457893 本文出自:[openXu的博客]   在上一篇文章<Activtiy完全 ...

  10. 关于在arm裸板编程时使用printf问题的解决方法

    在ARM裸板驱动编程中,是不允许程序直接调用C库程序的.为什么呢?因为此时kernel还没有被加载,所以在封装在kernel层的C库的API是用不了的,那怎么办? 在开发过程中,printf的功能我不 ...