类似于桶排序, 当然也可以用hash表
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e5 + 1;
int n, f[N], pos, maxx;
int main(){
cin >> n;
for(int i = 1, x; i <= n; i++) cin >> x, f[x]++;
for(int i = 1; i < N; i++) {
if(f[i] > maxx){
maxx = f[i];
pos = i;
}
}
cout<<pos<<endl;
return 0;
}
注意这里maxx要实施更新