所以,我有这个问题。我有这个矩阵:
1 1 1 1 1 1 1 1 1 1
1 1 0 0 0 1 0 T 0 1
H 0 0 1 1 1 0 1 1 1
1 1 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1
我需要建立一条从 H 开始的路径,它的坐标为 (3.1) 到 T(2.8) 我需要:我需要一个读取矩阵 A[1..M,1..N] 的程序,它本身代表一个迷宫使用元素 [0,1] 并读取 H,T 值。值 1 被认为是一堵墙,你不能穿过它。所以我之前发布了这个问题,我需要一些语法帮助。
我在伪代码中的看法是这样的:
var walkingDirection = up;
var walkingDirection1 = down;
var walkingDirection2 = right;
var walkingDirection3 = left;
while (not at T)
if (next field in walkingDirection is not 1)
go to next field in walkingDirection
else if
(next field in walkingDirection1 is not 1)
go to next field in walkingDirection1
else if
(next field in walkingDirection2 is not 1)
go to next field in walkingDirection2
else if
(next field in walkingDirection3 is not 1)
go to next field in walkingDirection3
end if
end while
请帮我一些语法
int myArray[5][10] = { {1 1 1 1 1 1 1 1 1 1},
{1 1 0 0 0 1 0 T 0 1},
{H 0 0 1 1 1 0 1 1 1},
{1 1 0 0 0 0 0 0 0 1},
{1 1 1 1 1 1 1 1 1 1} };
int H = myArray [3][1];
int T = myArray [2][8];
if myArray [a+1][b]==1)