1 #include <iostream> 2 using namespace std; 3 int arr[10005]; 4 int main() 5 { 6 ios::sync_with_stdio(false); 7 cin.tie(0); 8 int n; 9 cin >> n; 10 int x, maxn = 0; 11 for (int i = 0; i < n; i++) { 12 cin >> x; 13 maxn = x > maxn ? x : maxn; 14 arr[x]++; 15 } 16 int maxx = 0, index = 0; 17 for (int i = 1; i <= maxn; i++) { 18 if (arr[i] > maxx) { 19 maxx = arr[i]; 20 index = i; 21 } 22 } 23 cout << index << endl; 24 return 0; 25 }
原文地址:https://www.cnblogs.com/AntonLiu/p/11161346.html
时间: 2024-11-05 06:02:44