include
using namespace std;
struct node{
int nodesun[4][4];
int pre; //上一步在队列中的位置
int flag ; //步数标识,表示当前的步数为有效的
int value; //与目标的差距
int x,y; //空格坐标
}queue[1000];
//移动方向数组
int zx[4]={-1,0,1,0};
int zy[4]={0,-1,0,1};
//当前步数
int top;
int desti[4][4];//目标状态
int detect(struct node *p)//检查是否找到
{int i,j;
for(i=1;i<4;i++)
for(j=1;jnodesun[i][j]!=desti[i][j])
return 0;
return 1;
}
//打印
void printlj()
{int tempt;
int i,j;
tempt=top;
while(tempt!=0)
{ for(i=1;i<4;i++)
for(j=1;j<4;j++)
{cout<
temp;
queue[1].nodesun[i][j]=temp;
}
cout<<"请输入初始状态的空格的位置(行)"<>temp;
queue[1].x=temp;
cout<<"请输入初始状态的空格的位置(列)"<
2021-05-29 09:53:58
5KB
人工智能
1