1.数组存储路径,代码如下:
的#include <iostream的>
#include <queue>#include <cstdlib>
using namespace std;
结构点//点的结构体
{
point(int x,int y):x(x),y(y){} //带参构造
点(){}; //无参构造
point&operator =(point&a)//重载=
{
x = ax;
y = ay;
返回*这个;
}
点运算符+(point&a)//重载+
{
点t
tx = x + ax;
ty = y + ay;
返回t
}
bool operator ==(point&a)//重载==
{
return(x == ax)&&(y == ay);
}
int x;
int y
};
int main()
{
无符号索引= 0;
int arr [] [10] = {1,1,0,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,1,1,
1,1,1,0,0,0,0,0,0,0,
1,1,0,0,0,1,1,0,0,0,
1,1,1,1,0,1,1,1,1,0,
1,1,1,1,0,1,0,0,0,0,
1,1,1,1,0,1,0,1,1,1,
1,1,1,1,0,1,0,1,1,1,
1,1,1,1,0,0,0,1,1,1,
1,1,1,1,1,1,1,1,1};
bool isfind [10] [10];
memset(isfind,false,sizeof(bool)* 100);
点开始(0,2);
点终点(8,4);
点树[10] [10];
memset(tree,0,sizeof(point)* 100);
点det [4] = { {0,1},{1,0},{0,-1},{-1,0}};
我的
点电流;
if(!(Begin == End))
{
My.push(开始);
isfind [Begin.x] [Begin.y] = true;
而(真)
{
if(!My.empty())
{
Current = My.front();
My.pop();
}
其他
{
cout <<“查找失败”<< endl;
打破;
}
for(unsigned i &#