#include #include #include
int maze[10][10];
int flag = 0;
int DRV_SearchMaze(int max_line, int max_col, int line, int col)
{
if (flag)
{
return 0;
}
if (line == (max_line - 1) && col == (max_col - 1)) //是否到达迷宫边界
{
printf("(%d,%d)\n", line, col);
flag = 1;
return 0;
}
if ((col + 1 < max_col) && (maze[line][col + 1] == 0))//判断行上是否满足
{
printf("(%d,%d)\n", line, col);
DRV_SearchMaze(max_line, max_col, line, col + 1); //递归
}
if ((line + 1 < max_line) && (maze[line + 1][col] == 0))//判断列上是否满足
{
if (flag == 0)
{
printf("(%d,%d)\n", line, col);
DRV_SearchMaze(max_line, max_col, line + 1, col);//递归
}
}
return 0;
}
int main()
{
int line, col;
int i, j;
while (~scanf("%d %d", &line, &col))
{
flag = 0;
for (i = 0; i < line; i++)
{
for (j = 0; j < col; j++)
scanf("%d", &maze[i][j]);
}
DRV_SearchMaze(line, col, 0, 0);
}
return 0;
}