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 
  • 相关阅读:
    tomcat日志信息查看
    "".equals(xxx)和xxx.equals("")的区别
    javax.crypto.BadPaddingException: Given final block not properly padded解决方案
    去掉first li 的list图标
    浮动后的 <li> 如何在 <ul> 中居中显示?
    java冒泡排序
    JSP获取网络IP地址
    <%@ include %>导入的文件乱码
    out.print()与response.sendRedirect()
    王爽汇编语言第三版第5章实验4
  • 原文地址:https://www.cnblogs.com/dshn/p/4754466.html
Copyright © 2011-2022 走看看