| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 128879 | 邹子涵 | 19众数 | C++ | Compile Error | 0 MS | 0 KB | 606 | 2025-08-20 15:22:27 |
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n] ; //数组a赋值 for (int i = 0; i < n; i++) { cin >> a[i]; } int m = 1001; int b[m];//b[0]~b[10]分别用来保存1~10的出现次数 for (int i = 1; i < m; i++) { b[i] = 0; //出现次数初始化为0 } //遍历数组a for (int i = 0; i < n; i++) { int x = a[i]; b[x] = b[x] + 1; //次数+1 } //求数组b除b[0]外的最大值 int d = 1; for (int i = 2; i < m; i++) { if (b[i] > b[d]) { d = i; } } cout << d; return 0; }
Main.cc: In function 'int main()':
Main.cc:15:10: error: 'i' was not declared in this scope
cin >> a[i];
^
Main.cc: At global scope:
Main.cc:21:9: error: array bound is not an integer constant before ']' token
int b[m];//b[0]~b[10]分别用来保存1~10的出现次数
^
Main.cc:23:2: error: expected unqualified-id before 'for'
for (int i = 1; i < m; i++) {
^
Main.cc:23:18: error: 'i' does not name a type
for (int i = 1; i < m; i++) {
^
Main.cc:23:25: error: 'i' does not name a type
for (int i = 1; i < m; i++) {
^
Main.cc:29:2: error: expected unqualified-id before 'for'
for (int i = 0; i < n; i++) {
^
Main.cc:29:18: error: 'i' does not name a type
for (int i = 0; i < n; i++) {
^
Main.cc:29:25: error: 'i' does not name a type
for (int i = 0; i < n; i++) {
^
Main.cc:37:1: error: expected unqualified-id before 'for'
for (int i = 2; i < m; i++) {
^
Main.cc:37:17: error: 'i' does not name a type
for (int i = 2; i < m; i++) {
^
Main.cc:37:24: error: 'i' does not name a type
for (int i = 2; i < m; i++) {
^
Main.cc:45:2: error: 'cout' does not name a type
cout << d;
^
Main.cc:47:1: error: expected unqualified-id before 'return'
return 0;
^
Main.cc:49:2: error: expected declaration before '}' token
}
^