Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
151889 王晏林 最大值与最小值的差 C++ Compile Error 0 MS 0 KB 341 2026-04-19 11:54:03

Tests(0/0):


Code:

#include<bits/stdc++.h> using namespace std; int main() { int M,a[10001{},max,min,b,i; cin>>M; for(int i=1;i<=m;i++){ cin>>a[i]; if(i==1) max=min=a[i]; if(a[i]>max) max=a[i]; if(a[i]<min) min=a[i]; } b=max-min; cout<<b<<endl return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:5:18: error: expected ']' before '{' token
     int M,a[10001{},max,min,b,i;
                  ^
Main.cc:5:20: error: expected primary-expression before ',' token
     int M,a[10001{},max,min,b,i;
                    ^
Main.cc:5:29: error: 'b' was not declared in this scope
     int M,a[10001{},max,min,b,i;
                             ^
Main.cc:5:31: error: 'i' was not declared in this scope
     int M,a[10001{},max,min,b,i;
                               ^
Main.cc:7:20: error: 'm' was not declared in this scope
     for(int i=1;i<=m;i++){
                    ^
Main.cc:8:14: error: 'a' was not declared in this scope
         cin>>a[i];
              ^
Main.cc:16:8: error: invalid operands of types '' and '' to binary 'operator-'
  b=max-min;
        ^