#include <bits/stdc++.h>
using namespace std;
int n,a[35][35],b[35][35];
void find(int i,int j){
if(a[i][j]||b[i][j]||i<1||i>n||j<1||j>n) return;
b[i][j]=1;
find(i-1,j);find(i+1,j);
find(i,j+1);find(i,j-1);
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>a[i][j];
if(a[i][j]==0) b[i][j]=0;
else b[i][j]=1;
}
}
find(0,0);
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(a[i][j]==0) cout<<"2 ";
else cout<<b[i][j]<<" ";
}
cout<<endl;
}
return 0;
}
把外圈“0”怎么变回来
只做了把所有“0”都刷成“2”了