-->
当前位置:首页 > 题库

PROGRAMMING:Maze depth strategy

Luz5年前 (2021-05-10)题库365
How a mouse trapped in a maze finds its way out. Mice want to systematically try all the paths and walk out of the maze. If it reaches a dead end, it returns to the previous location and tries a new path. In each position, the mouse can move in eight directions, starting from due east, clockwise. No matter how far away it is from the exit, it always tries in this order. When it reaches a dead end, the mouse will "backtrack". Labyrinth has only one entrance and one exit. The design program needs to output a path of labyrinth. Maze is represented by two-dimensional memory structure, 1 represents obstacle and 0 represents path; The backtracking method is used to design the algorithm to solve the path. The requirements are as follows:
1. Realize the operation of stack;
2. The output path of backtracking algorithm is realized by stack;
###Input format:
The input includes three parts
The first input is the size of the maze; The second input is the state of maze; The third input is the entry and exit locations
###Output format:
The reverse output explores the path, including the entrance and exit positions. Semicolons are used between each position; separate.
###Input example:
```in
nine
1 1 1 1 1 1 1 1 1
1 0 0 1 1 0 1 1 1
1 1 0 0 0 0 0 0 1
1 0 1 0 0 1 1 1 1
1 0 1 1 1 0 0 1 1
1 1 0 0 1 0 0 0 1
1 0 1 1 0 0 0 1 1
1 1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 1 1
1 1 7 7
```
###Output example:
```out
7 7; 6 6; 5 7; 4 6; 4 5; 3 4; 2 5; 2 4; 2 3; 1 2; 1 1;
```







answer:If there is no answer, please comment