-
定义一个二维数组:
int maze[5][5] = {
0, 1, 0, 0, 0,
0, 1, 0, 1, 0,
0, 0, 0, 0, 0,
0, 1, 1, 1, 0,
0, 0, 0, 1, 0,
};
它表示一个迷宫,其中的1表示墙壁,0表示可以走的路,只能横着走或竖着走,不能斜着走,要求编程序找出从左上角到右下角的最短路线。输入描述
一个5 × 5的二维数组,表示一个迷宫。数据保证有唯一解。输出描述
左上角到右下角的最短路径,格式如样例所示。输入例子
0 1 0 0 0
0 1 0 1 0
0 0 0 0 0
0 1 1 1 0
0 0 0 1 0
输出例子
(0, 0)
(1, 0)
(2, 0)
(2, 1)
(2, 2)
(2, 3)
(2, 4)
(3, 4)
(4, 4) ...
阅读题目
问答题
经典指数
-
-
-
-
-
-
-
-
-
There is a board with 100 * 100 grids as shown below. The left-top gird
is denoted as (1, 1) and the right-bottom grid is (100, 100).
We may apply three commands to the board:
1. WHITE x, y, L // Paint a white square on the board,
// the square is defined by left-top grid (x, y)
// and right-bottom grid (x+L-1, y+L-1)
2. BLACK x, y, L // Paint a black square on the board,
// the square is defined b ...
阅读题目
问答题
经典指数