You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
471 B
C++
24 lines
471 B
C++
#include <iostream>
|
|
#include <string>
|
|
#include <map>
|
|
#include <algorithm>
|
|
using namespace std;
|
|
bool cmp(const pair<string,int>& lhs,const pair<string,int>& rhs)
|
|
{
|
|
return lhs.second<rhs.second;
|
|
}
|
|
int main()
|
|
{
|
|
map<string,int> m;
|
|
string s;
|
|
int n;
|
|
while(cin>>n,n)
|
|
{
|
|
m.clear();
|
|
for(int i=0; i<n; i++)
|
|
cin>>s,m[s]++;
|
|
cout<<max_element(m.begin(),m.end(),cmp)->first<<endl;
|
|
}
|
|
return 0;
|
|
}
|