Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
148391 张晓冉 22相差2的数的个数 C++ Compile Error 0 MS 0 KB 928 2026-02-12 20:15:45

Tests(0/0):


Code:

#include <bits/stdc++.h> using namespace std; int f[105]; int n; int main() { cin >> n; for (int i = 0; i < n; i++) { int num; cin >> num; f[num]++; } int maxn = 0; for (int i = 0; i <= 98; i++) { int c = f[i] + f[i + 1] + f[i + 2]; maxn = max(maxn, c); } maxn = max(maxn, f[99] + f[100]); maxn = max(maxn, f[100]); cout << maxn << endl; return 0; } #include <bits/stdc++.h> using namespace std; int f[105]; int n; int main() { cin >> n; for (int i = 0; i < n; i++) { int num; cin >> num; f[num]++; } int maxn = 0; for (int i = 0; i <= 98; i++) { int c = f[i] + f[i + 1] + f[i + 2]; maxn = max(maxn, c); } maxn = max(maxn, f[99] + f[100]); maxn = max(maxn, f[100]); cout << maxn << endl; return 0; }


Run Info:

Main.cc:22:3: error: stray '#' in program
 } #include  
   ^
Main.cc:22:4: error: 'include' does not name a type
 } #include  
    ^
Main.cc:24:10: error: redefinition of 'int f [105]'
 int f[105]; 
          ^
Main.cc:3:5: note: 'int f [105]' previously declared here
 int f[105]; 
     ^
Main.cc:25:8: error: redefinition of 'int n'
    int n; 
        ^
Main.cc:4:8: note: 'int n' previously declared here
    int n; 
        ^
Main.cc: In function 'int main()':
Main.cc:26:5: error: redefinition of 'int main()'
 int main() { 
     ^
Main.cc:5:5: note: 'int main()' previously defined here
 int main() { 
     ^