import java.util.*;
class Position{//位置,在第几行第几列
public Position(){//无参的构造函数
}
public Position(int row, int col){//有参的构造函数
this.col = col;
this.row = row;
}
public String toString(){//重写toString()方法
return "(" + row + " ," + col + ")";
}
int row;
int col;
}
class Maze{//迷宫类
public Maze(){
maze = new int[15][15];//初始化迷宫
stack = new Stack<Position>();//初始化栈
p = new boolean[15][15];//新的空间
}
/*
* 构造迷宫
*/
public void init(){//回溯迷宫,查看是否有出路
Scanner scanner = new Scanner(System.in);
System.out.println("请输入迷宫的行数");//定义行
row = scanner.nextInt();
System.out.println("请输入迷宫的列数");//定义列
col = scanner.nextInt();
System.out.println("请输入" + row + "行" + col + "列的迷宫");//输入具体的迷宫内容
int temp = 0;//定义一个变量
for(int i = 0; i < row; ++i) {
for(int j = 0; j < col; ++j) {
temp = scanner.nextInt();
maze[i][j] = temp;//输入内容放入迷宫内
p[i][j] = false;//p二维数组全都初始化为false
}
}
}
/*
* 回溯迷宫,查看是否有出路
*/
public void findPath(){//查找路径
// 给原始迷宫的周围家一圈围墙
int temp[][] = new int[row + 2][col + 2];//新的迷宫
for(int i = 0; i < row + 2; ++i) {
for(int j = 0; j < col + 2; ++j) {
temp[0][j] = 1;//周围一圈的墙
temp[row + 1][j] = 1;
temp[i][0] = temp[i][col + 1] = 1;
}
}
// 将原始迷宫复制到新的迷宫中