HDU 1004 Let the Balloon Rise

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
    char str[1050][20];
    int a[1050],i,j,k,n;
    while(cin>>n,n)
    {
        getchar();
        memset(a,0,sizeof(a));
        int max=0;
        for(i=0; i<n; i++)
        {
            gets(str[i]);
            if(i>0)
            {
                for(j=0; j<i; j++)
                    if(strcmp(str[i],str[j])==0)
                    {
                        a[j]++;
                        break;
                    }
                if(a[j]>max)
                    max=a[j];
            }
        }
        for(i=0; i<n; i++)
            if(a[i]==max)
                cout<<str[i]<<endl;

    }
    return 0;
}

你可能感兴趣的:(C++,HDU)