zoukankan      html  css  js  c++  java
  • HDU 1004:Let the Balloon Rise

    Let the Balloon Rise

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


    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
     

    Recommend
    JGShining   |   We have carefully selected several similar problems for you:  1003 1019 1013 1012 1020 
     

    你  离  开  了  ,  我  的  世  界  里  只  剩  下  雨  。  。  。

    #include<stdio.h>
    #include<string.h>
    #include<iostream>
    using namespace std;
    int main()
    {
        int i,a,max[1005],ma=0,jj=0;
        string s[1005];
        while(cin>>a&&a)
        {
            ma=0,jj=0;
            memset(max,0,sizeof(max));
            for(i=0; i<a; i++)
            {
                cin>>s[i];
                for(int k=0; k<i; k++)
                    if(s[k]==s[i])max[i]++;
            }
            for(i=0; i<a; i++)
                if(ma<max[i])
                    ma=max[i],jj=i;
            cout<<s[jj]<<endl;
        }
        return 0;
    }
    

  • 相关阅读:
    C语言寒假大作战01
    C语言I作业12—学期总结
    C语言I博客作业11
    C语言I博客作业10
    C语言I博客作业09
    C语言I博客作业08
    计算机组成与设计 复习
    概率论与数理统计 期末复习
    SPM(Software Project Management)课程感想
    Software Project Management_JUnit && Maven
  • 原文地址:https://www.cnblogs.com/im0qianqian/p/5989601.html
Copyright © 2011-2022 走看看