这代码为什么错了???
#include <vector>
#include <iostream>
using namespace std;
vector<vector<int>> mat{
{0, 1, 0},
{0, 0, 0},
{0, 0, 0}
};
vector<vector<bool>> filled{
{0, 0, 0},
{0, 0, 0},
{0, 0, 0}
};
bool ok(vector<vector<bool>> v){
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
if(!v[i][j]) return false;
}
}
return true;
}
int main(){
short n;
cin >> n;
// 1. 锁定当前位置及填写的数
short nowx = 0;
short nowy = 1;
short last = 1;
// 2. while条件: 未填满
while(!ok(filled)){
// 3. 第二步
// 3-1. 更新锁定位置
if(nowx == 0) nowx = 2;
else nowx -= 1;
if(nowy == 2) nowy = 0;
else nowy += 1;
// 3-2. 验证并填入
if(!filled[nowx][nowy]){
last++;
mat[nowx][nowy] = last;
filled[nowx][nowy] = true;
continue;
}
// 4. 第三步
// 4-1. 更新锁定位置
if(nowx == 0) nowx = 2;
else nowx -= 1;
// 4-2. 填入
last++;
mat[nowx][nowy] = last;
filled[nowx][nowy] = true;
}
// 5. 输出
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
cout << mat[i][j] << ' ';
}
cout << endl;
}
return 0;
}