#include <string>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main()
{
int T;
while (cin >> T&&T!=0)
{
map<string,int> Color;
string s;
for (int i = 0; i < T; i++)
{
cin >> s;
Color[s]++;
}
int maxS = 0;
int maxN = 0;
int i = 0;
for (auto a : Color)
{
if (maxN < a.second)
{
maxN = a.second;
maxS = i;
}
i++;
}
i = 0;
for (auto a : Color)
{
if (i == maxS)
{
cout << a.first << endl;
break;
}
i++;
}
}
return 0;
}
杭电OJ 1004 求出现次数最多的字符串
最新推荐文章于 2021-03-09 17:57:57 发布