Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
126842 包老师 19众数 C++ Accepted 5 MS 280 KB 430 2025-07-22 12:56:27

Tests(11/11):


Code:

#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; //初始化数组b int b[1001]; for (int i = 1; i <= 1000; i++) { b[i] = 0; } for (int i = 0; i < n; i++) { int x; cin >> x; b[x]++; } //接下来求数组b最大值的下标 int max = 1; //为什么不写0? for (int i = 2; i <= 1000; i++) { if (b[i] > b[max]) { max = i; } } cout << max; return 0; }