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

    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
     1 #include<stdio.h>
     2 #include<string.h>
     3 int main()
     4 {
     5     int T;
     6     int k=10;
     7     int e[k] = {0,1,2,3,4,5,6,7,8,9};
     8     while(scanf("%d",&T)==1)
     9     {
    10         getchar();
    11         if(T==0)
    12             break;
    13         else
    14         {
    15             char a[1000][16],b[16],c[16];/*以前一直以为可以用数组变量,但这次用a[T][16]一提交就编译出错,虽然在dev上编译时通过的,长个记性*/
    16             memset(a,0,sizeof(a));
    17             memset(b,0,sizeof(b));
    18             memset(c,0,sizeof(c));
    19             int i,j,max=-1,m=0;
    20             for(i=0;i<T;i++)
    21             {
    22                 scanf("%s",a[i]);
    23             }
    24             for(i=0;i<T;i++)
    25             {    
    26                 for(j=0;j<T;j++)
    27                 {
    28                     if(stricmp(a[i],a[j])==0)
    29                         m++;
    30                 }
    31                 if(m>max)
    32                 {
    33                     max=m;
    34                     strcpy(c,a[i]);
    35                 }
    36                 m=0;
    37             }
    38             printf("%s
    ",c);
    39         }        
    40     }
    41 }
  • 相关阅读:
    php Windows系统 wamp集成环境下redis的使用
    IO流文件拷贝
    IO流框架
    Map集合
    泛型
    Deque(队列)
    List接口
    Iterator接口(迭代器)
    Java中的异常详解
    Java中的正则表达式
  • 原文地址:https://www.cnblogs.com/a1225234/p/4493459.html
Copyright © 2011-2022 走看看