一个过了的代码,有些地方不懂,在88888那里

P1162 填涂颜色

希望更丰富的展现?[使用Markdown](https://www.luogu.org/wiki/show?name=帮助:markdown)
by mt19337 @ 2019-07-20 15:53:05


替他发一下格式化过的代码(VS Code大法好) ```c++ #include <bits/stdc++.h> using namespace std; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; int m, n, t = 0, x, y, d; int a[50][50]; void asd(int e, int o) { int w = 1; int dl[1000][3]; 888888 a[e + 1][o + 1] = 2; dl[1][1] = e + 1; dl[1][2] = o + 1; 8888888 do { t++; for (int i = 0; i <= 3; i++) { x = dl[t][1] + dx[i]; y = dl[t][2] + dy[i]; if ((x >= 0) && (x < d) && (y >= 0) && (y < d) && a[x][y] == 0) { w++; dl[w][1] = x; dl[w][2] = y; a[x][y] = 2; } } } while (t < w) ; return; } int main() { bool f = 0; cin >> d; for (int i = 1; i <= d; i++) for (int j = 1; j <= d; j++) { cin >> a[i][j]; } for (int i = 1; i <= d; i++) { for (int j = 1; j <= d; j++) { if (a[i][j] == 1) { asd(i, j); f = 1; break; } } if (f) break; } for (int i = 1; i <= d; i++) { for (int j = 1; j <= d; j++) { cout << a[i][j] << " "; } cout << endl; } return 0; } ```
by Raining @ 2019-07-30 10:13:51


|