Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
65978 谢绍澜 蛇形矩阵 C++ Compile Error 0 MS 0 KB 602 2024-02-29 18:59:47

Tests(0/0):


Code:

# include<iostream> using namespace std; int main() int n,sum=1; cin>>n; int a[n][n]; for(int i=0;i<n;i++){ if(i%2==0){ for(int j=0;j<n;j++){ a[i][j]=sum; sum++; } } else{ for(int j=0;j<n;j++){ a[j][i]=sum; sum++; } } } for(int i=0;i<n;i++){ for(int j=0;j<n;j++) print("%3d",a[i][j]) cout<<endl; } return 0; }


Run Info:

Main.cc:4:5: error: expected initializer before 'int'
     int n,sum=1;
     ^
Main.cc:5:5: error: 'cin' does not name a type
     cin>>n;
     ^
Main.cc:6:11: error: 'n' was not declared in this scope
     int a[n][n];
           ^
Main.cc:6:14: error: 'n' was not declared in this scope
     int a[n][n];
              ^
Main.cc:7:5: error: expected unqualified-id before 'for'
     for(int i=0;i