#include<iostream>
#include<map>
using namespace std;
int main()
{
// 读入一共有多少个数据 -> n
int n;
cin>>n;
// 使用 map容器 来管理
map<int,int> store;
int input;
for(int k=0;k<n;k++)
{
cin>>input;
// map容器 "key值" 表示出现的正整数
// map容器 "value" 表示该正整数出现的个数
if(store.count(input)>0) store[input]++; //如果已经出现过
else store.insert( std::pair<int,int>(input,1) ); //正整数没有出现过
}
int max = 0; // 代表value
int index = 0; // 代表索引,目标是寻找索引最小的数
for(map<int,int>::iterator it=store.begin();it!=store.end();it++)
{
if(it->second==max) index = min(index,it->first);
if(it->second>max)
{
max = it->second;
index = it->first;
}
}
cout<<index<<endl;
return 0;
}
这里需要提醒的是,容器的迭代器至少在官网上还是需要老老实实按照去写,不能使用C++11的auto关键字
如果使用的话,在Dev-c++中是无法通过编译,所以在平台上也是直接报编译错误,0分