#include <cstdio>
#include <iostream>
#define MAX_N 10
#define MAX_M 10
using namespace std;
const int INF = 100000000;
// 使用typedef会更加方便一点
typedef pair<int,int> p;
// 输入
char maze[MAX_N][MAX_M+1]; // 表示迷宫的字符串数组
int N,M;
int sx,sy; // 起点坐标
int gx,gy; // 终点坐标
int d[MAX_N][MAX_M]; // 到各个位置的最短距离的数组
// 4个方向移动的向量
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
// 求从(sx,sy)到(gx,gy)的最短距离
// 如果无法到达,则是INF
int bfs(){
queue<P> que;
// 把所有的位置都初始化为INF
for (int i = 0;i < N;i ++)
for (int j = 0;j < M;j ++)d[i][j] = INF;
// 将起点加入队列,并把这一地点的距离设置为0
que.push(P(sx,sy));
d[sx][sy] = 0;
// 不断循环直到队列的长度为0
while (que.size()){
//
}
}
/*
#S######.#
......#..#
.#.##.##.#
.#........
##.##.####
....#....#
.#######.#
....#.....
.####.###.
....#...G#
*/
一道看起来简单,实际有点复杂的问题。
下次在回答。