C - Let the Balloon Rise(10)

1183 ワード

Description
ACMの試合では、問題を解決するたびに、風船を手に入れることができます.異なる色の風船はあなたを代表して異なる問題を解決しました.WJLさんが参加したACMの試合で、場面にN個の風船があることに気づき、風船の色を上手に話した.風船の数が一番多い色を見つけるプログラムを作ってください.
Input
複数のサンプル入力があります.各サンプルの最初の行には、合計N個の風船を表す整数N(0Output
各サンプルデータのセットについて、その色の風船を単独の行で最も多く出力します.(データ保証出力は一意)
Sample Input
5
green
red
blue
red
red
3
pink
orange
pink
0

Sample Output
red
pink
#include 
#include 
#include
#include
#include
using namespace std;
struct st
{
    int sum;
    char s[20];
}a[1001],t;
int main()
{int n;
while(scanf("%d",&n)!=EOF)
{
    if(n==0)break;
    int i,j;
    for(i=0;ia[j+1].sum)
            {
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
    }
    printf("%s
",a[i].s); } return 0; }