#include <iostream>
#include <map>
using namespace std;
int main()
{
int n;
map<int, int> dict;
while(cin >> n)
{
int tmp;
for(int i = 0; i < n; i++)
{
cin >> tmp;
dict[tmp]++; //默认是0;
}
int max = 0;
int ans;
map<int, int>::iterator it;
for(it = dict.begin(); it != dict.end(); it++)
{
if(max < it->second)
{
max = it->second;
ans = it->first;
}
}
dict.clear();
cout << ans << endl;
}
return 0;
}
复旦18年机考-求众数(map)
最新推荐文章于 2023-03-10 12:04:27 发布