#include
#include
#include
using namespace std;
map mp;
int main()
{
int n;
while (cin>>n, n!=0)
{
string s,p;
int mx=0;
for (int i=0;i {
cin>>s;
if (mp.find(s)==mp.end())
{
mp[s]=1;
if (1>mx)
{
mx=1;
p=s;
}
}
else
{
mp[s]++;
if (mp[s]>mx)
{
mx=mp[s];
p=s;
}
}
}
cout << p << endl;
}
}
map<string,string> mp; //定义应该如此。。
string s,p;
int mx = 0;
while(1)
{
cin >> s;
if (mp.find(s) == mp.end()) // 查找map的字符串,但是 s 新输出的,除非有输入相同的字符串,否则一致为ture
{
mp[s]=1;
if (1>mx) //
{
mx=1;
p=s;
}
}
else
{
//mp[s].;
if(mp[s].length() > mx) //
{
mx = mp[s].length();
p=s;
}
}
}
就是手动输入字符串,添加到map当中。。。