S为入口
E为出口
#为障碍
-为可通过路径
思路:通过BFS进行广搜,若搜到即为最短路径,若搜不到则不存在(当节点队列为空时)
代码:
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
class Point{
public:
Point(){
vis = 0;
};
Point(const Point& p){
x = p.x;
y = p.y;
data = p.data;
vis = p.vis;
};
public:
int x;
int y;
int vis;
char data;
};
Point mp[110][110];
int height,width;;
int x_move[4] = {-1,1,0,0};
int y_move[4] = {0,0,-1,1};
bool check(Point p){
if(p.x >= 1 && p.x <= width && p.y >= 1 && p.y <= height){
if(p.data == '-' || p.data =