#include <iostream>
#include <string>
using namespace std;
struct Flags
{
string str;
int cnt;
};
int main()
{
int n;
Flags s[1010];
bool exist;
int max, wheremax;
while(cin >> n, n != 0)
{
for(int i = 0; i < n; ++i)
s[i].cnt = 0;
for(int i = 0; i < n; ++i)
{
cin >> s[i].str;
exist = false;
for(int j = 0; j < i; ++j)
{
if(s[i].str == s[j].str)
{
++ s[j].cnt;
exist = true;
break;
}
}
if(!exist)
++ s[i].cnt;
}
max = 1;
wheremax = 0;
for(int i = 0; i< n; ++i)
{
if(s[i].cnt > max)
{
max = s[i].cnt;
wheremax = i;
}
}
cout << s[wheremax].str << endl;
}
return 0;
}
终于AC了!
HDU1004
最新推荐文章于 2014-07-30 18:28:59 发布