C++ 代码
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
for(int i = 0; i < n; i++)
cin >> a[i];
sort(a,a+n);
int max = 1 ,s = a[0];
int temp = 1;
for(int i = 1; i < n; i++)
if(a[i-1] == a[i]){
temp++;
if(temp > max){
max = temp;
s = a[i];
}
}
else if(a[i-1] != a[i]){
if(temp > max){
max = temp;
s = a[i];
}
temp = 1;
}
cout << s << endl;
return 0;
}