- 15
- 0
- 约6.31千字
- 约 8页
- 2016-12-25 发布于重庆
- 举报
代码:
#include stdafx.h
#include malloc.h
# define N 15
typedef struct Jiedian{
int a[3][3];//当前八数码阵列
}*Jie;
struct Open{
Jie Op;//当前节点typedef
int fa;//在closed中父节点下标
int h;//此行表格是否为空 0为空,1为满;
int x;//启发函数h(x)的值
int m,n;//结点的空格所在坐标下标,m,n分别为横,纵坐标
int grade;//执行优先级别,为1时优先级高。
}OPEN[N];
struct Closed{
int h;//父节点下标typedef
Jie Jc;//当前节点的指针
int son;//父节点的指针
}CLOSED[5000];
int Ha(int c[3][3],int d[3][3])//定义启发函数d[][]为目标数组
{
int i,j,h=0;
for(i=0;i3;i++)
for(j=0;j3;j++)
if(c[i][j]!=d[i][j])
h++;
return h;
}
bool equal(int a[][3],int b[][3]){//判断两矩阵是否相等
int i,j;
for(i=0;i
原创力文档

文档评论(0)