zoukankan      html  css  js  c++  java
  • HDU1004Let the Balloon Rise

    Let the Balloon Rise

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


    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
     
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    using namespace std;
    char a[1005][20];
    int num[1005];
    int ii;
    int main()
    {
        int n;
        while(~scanf("%d",&n))
        {
            if(n==0)
            break;
            int maxs=-1;
            for(int i=0;i<n;i++)
            {
                scanf("%s",a[i]);
            }
            for(int i=0;i<n-1;i++)
            {
                int t=0;
                for(int j=i+1;j<n;j++)
                {
                    if(!strcmp(a[i],a[j]))
                    {
                        t++;
                    }
                }
                if(t>maxs)
                {
                    maxs=t;
                    ii=i;
                    //strcpy(b,a[i]);   //不能用,,
                }
            }
            printf("%s
    ",a[ii]);
        }
    }

     

    Recommend
    JGShining   |   We have carefully selected several similar problems for you:  1002 1008 1005 1019 1021 
  • 相关阅读:
    Visual Studio for Application 内幕之二(转载)
    查找数组中极值
    .net中HashTable的最大容量
    返回数组中所有元素被第一个元素除的结果
    将json转换为DataTable
    ASP.NET面试题(推荐_有答案) FX
    [转]U盘启动制作工具|大白菜启动制作工具
    使用QFileDialog 同时选择 文件和文件夹
    [转]如何用SQL命令修改字段名称
    小朋友 老师 笑话
  • 原文地址:https://www.cnblogs.com/dshn/p/4754466.html
Copyright © 2011-2022 走看看