文章
27
粉丝
492
获赞
10
访问
268.9k
import java.util.LinkedList;
import java.util.Scanner;
public class Main {
static int dx[]= {1,0,-1,0};//下,左,上,右
static int dy[]= {0,-1,0,1};
public static class Point {
int x;
int y;
int t;
// public Point() {
// super();
// }
public Point(int x, int y, int t) {
super();
this.x = x;
this.y = y;
this.t = t;
}
}
public static char[][] bfs(int x,int y,char map[][],int s){
int[][] v=new int[32][32];
LinkedList<Point> q=new LinkedList<>();
q.offer(new Point(x,y,0));
v[x][y]=1;
map[x][y]='#';
while(!q.isEmpty()) {
Point sp=q.poll();
if(sp.t==s)
break;
for(int i=0;i<4;i++) {
int xn=sp.x+dx[i];
int yn=sp.y+dy[i];
if(map[xn][yn]=='.'&&v[xn][yn]==0) {
q.offer(new Point(xn,yn,sp.t+1));
v[xn][yn]=1;
map[xn][yn]='#';
}
}
}
return map;
}
public static void main...
登录后发布评论
使用对数器搞一搞
使用对数器搞一搞
建议使用对数器搞一搞