This year, they decide to leave this lovely job to you.
A test case with N = 0 terminates the input and this test case is not to be processed.
pink
題意:給出n個字符串,輸出出現次數最多的字符串
#include <iostream>
#include <cstring>
#include<string>
using namespace std;
int main()
{
int n,i,j;
int a[1001];
string s[1001];
while(cin>>n&&n)
{
int maxn=-1;
for(i=0; i<n; i++)
{
a[i]=0;
cin>>s[i];
for(j=0; j <i; j++)
if(s[i]==s[j])
a[i]++;
}
int num=0;
for(i=0; i<n; i++)
if(maxn<a[i])
{
maxn=a[i];
num=i;
}
cout<<s[num]<<endl;
}
}