Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
2830 邓小龙 方阵填数 C++ Compile Error 0 MS 0 KB 715 2024-03-02 18:12:16

Tests(0/0):


Code:

# include<iostream> using namespace std; int main(){ int n; cin>>n; int juzhen[n][n]={}, a = -1, b = n-1, way = 2, out = 1; while(out <= n*n){ if(way == 1){ if(juzhen[a][b+1]!=0||b>n-2){ way++; continue; } b++; } else if(way == 2){ if(juzhen[a+1][b]!=0||a>n-2){ way++; continue; } a++; } else if(way == 3){ if(juzhen[a][b-1]!=0||b<1){ way++; continue; } b--; } else if(way == 4){ if(juzhen[a-1][b]!=0||a<1){ way = 1; continue; } a--; } juzhen[a][b] = out; out++; } for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++)cout<<juzhen[i][j]<<" "; cout<<endl; } return 0; }


Run Info:

Main.cc: In function 'int main()':
Main.cc:6:20: error: variable-sized object 'juzhen' may not be initialized
  int juzhen[n][n]={}, a = -1, b = n-1, way = 2, out = 1;
                    ^