一、问题描述
给定一个n*m大小的迷宫,其中*代表不可通过的墙壁,而“.”代表平地,S表示起点,T代表终点。移动过程中,如果当前位置是(x,y)(下标从0开始),且每次只能前往上下左右(x,y+1)、(x,y-1)、(x-1,y)、(x+1,y)四个位置的平地,求从起点S到达终点T的最少步数。
` ` ` ` `
` * ` * `
` * S * `
` * * * `
` ` ` T *
在上面的样例中,S的坐标为(2,2),T的坐标为(4,3)。
二、代码实现
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
using namespace std;
const int maxn=100;
struct Node
{
int x,y;
int step;
}S,T,node;
int n,m; //n行,m列
char maze[maxn]