lhr123 @ 2020-10-28 20:30:33
#include <bits/stdc++.h>
using namespace std;
int x,y;
int main(){
int n,a[100][100];
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++) cin>>a[i][j];
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(a[i+1][j]==1) a[i+2][j]=2;
else if(a[i-1][j]==1) a[i-1][j]=2;
else if(a[i][j+1]==1) a[i][j+1]=2;
else if(a[i][j-1]==1) a[i][j-1]=2;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++) cout<<a[i][j]<<" ";
cout<<endl;
}
return 0;
}
by JJA_ @ 2020-10-28 20:31:55
da?WA?
by rhyyy1 @ 2020-10-28 20:45:54
emmm这题要用flood-fill