一.题目

分析:就是扫雷游戏规则,很简单的一道bfs题目,将地雷入队搜索周围就行,需要注意的是,要先将地雷的数值初始化为比最大数据加1的值,要不然会和地雷数量重复,处理起来优点麻烦
import java.util.Scanner;
import java.util.LinkedList;
import java.util.Queue;
// 1:无需package
// 2: 类名必须Main, 不可修改
public class Main {
//对应8个位置的方向向量
public static int[] dx = {0,1,0,-1,1,1,-1,-1};
public static int[] dy = {1,0,-1,0,1,-1,-1,1};
static class pair{
int x;
int y;
public pair(int x,int y)
{
this.x = x;
this.y = y;
}
}
public static Queue<pair> queue = new LinkedList<pair>();
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int m = scan.nextInt();
int[][] map = new int[n][m];
for(int i = 0;i<n;i++)
{

最低0.47元/天 解锁文章
3552

被折叠的 条评论
为什么被折叠?



