描述
题解
水题一道,处理方法多了去,我用的map
躺过。
代码
#include <iostream>
#include <map>
#include <string>
using namespace std;
string balloon;
map<string, int>::iterator it;
int main(int argc, const char * argv[])
{
int N;
while (cin >> N && N)
{
map<string, int> balloons;
for (int i = 0; i < N; i++)
{
cin >> balloon;
balloons[balloon]++;
}
map<string, int>::iterator it_ = it = balloons.begin();
for (; it != balloons.end(); it++)
{
if (it->second > it_->second)
{
it_ = it;
}
}
cout << it_->first << '\n';
}
return 0;
}