huangruize3 @ 2024-12-06 13:30:24
#include<bits/stdc++.h>
using namespace std;
typedef pair<int ,int> ll;
int mp[40][40];
bool vis[40][40];
int n;
int fx[5]={0,0,1,0,-1};
int fy[5]={0,1,0,-1,0};
void bfs(int x,int y){
queue<ll>q;
q.push(make_pair(x,y));
while(q.size()){
ll xxx=q.front();
q.pop();
for(int i=0;i<4;i++){
int nx,ny;
nx=xxx.first+fx[i];
ny=xxx.second+fy[i];
if(nx>=1&&nx<=n&&ny>=1&&ny<=n&&mp[nx][ny]==0&&!vis[nx][ny]){
vis[nx][ny]=0;
q.push(make_pair(nx,ny));
}
}
}
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
cin>>mp[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(vis[i][j]==0&&mp[i][j]==0){
cout<<2<<' ';
}else{
cout<<mp[i][j]<<' ';
}
}
cout<<endl;
}
return 0;
}
by FatLLion @ 2024-12-14 11:30:46
你这直接把所有
by huangruize3 @ 2024-12-14 16:31:30
@FatLLion 对呀,不然我就不发
by FatLLion @ 2024-12-14 17:02:04
你也没调用
by huangruize3 @ 2024-12-14 17:47:12
@FatLLion原来如此
by FatLLion @ 2024-12-14 18:43:08
不是你
by huangruize3 @ 2024-12-14 19:58:18
@FatLLion哪错了
by FatLLion @ 2024-12-14 22:32:07
你的
by huangruize3 @ 2024-12-15 20:06:41
@FatLLion 所以怎么写?