4 楼
yjlh1234 [专家分:420] 发布于 2005-09-13 11:15:00
//以下是主函数
//----------------------------------------------
main()
{struct node *temp;
struct node *head_open;
struct node *tail_open;
struct node *head_close;
struct node *tail_close;
struct node **open_head;
struct node **open_tail;
struct node **close_head;
struct node **close_tail;
struct node *node_son[5];
struct node *best_node;
int num[5];
int a[12][12]={1,1,1,1,1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,1,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,0,0,0,0,0,0,0,0,0,0,1,
1,1,1,1,1,1,1,1,1,1,1,1
};
int i=1;
int j=1;
int desert_x=4;
int desert_y=7;
int start_x=2;
int start_y=4;
int valed=0;
//---以上是定义变量
//---以下是初始化open表和close表
head_open=(struct node *)malloc(sizeof(struct node));
head_open->x=start_x;
head_open->y=start_y;
head_open->num=NUM(head_open->x,head_open->y);
head_open->valed=0;
head_open->val=head_open->valed+F(head_open->x,head_open->y,desert_x,desert_y,a[head_open->x][head_open->y]);
head_open->f=F(head_open->x,head_open->y,desert_x,desert_y,a[head_open->x][head_open->y]);
head_open->father_node=NULL;
head_open->next=NULL;
head_open->front=NULL;
tail_open=head_open;
open_head=&head_open;
open_tail=&tail_open;
close_head=close_tail=NULL;
close_head=&head_close;
close_tail=&tail_close;