456
来源:互联网 发布:网络虚拟手机号申请 编辑:程序博客网 时间:2024/06/08 13:15
#include <stdio.h>
#include <math.h>
#define MaxLength 100 //�������ȶ��У�Open��������
#define Height 15 //��ͼ�߶�
#define Width 20 //��ͼ���
#define Reachable 0 //���Ե���Ľ��
#define Bar 1 //�ϰ���
#define Pass 2 //��Ҫ�ߵIJ���
#define Source 3 //���
#define Destination 4 //�յ�
#define Sequential 0 //˳�����
#define NoSolution 2 //����
#define Infinity 0xfffffff
#define East (1 << 0)
#define South_East (1 << 1)
#define South (1 << 2)
#define South_West (1 << 3)
#define West (1 << 4)
#define North_West (1 << 5)
#define North (1 << 6)
#define North_East (1 << 7)
typedef struct
{
signed char x, y;
} Point;
const Point dir[8] =
{
{0, 1}, // East
{1, 1}, // South_East
{1, 0}, // South
{1, -1}, // South_West
{0, -1}, // West
{-1, -1}, // North_West
{-1, 0}, // North
{-1, 1} // North_East
};
unsigned char within(int x, int y)
{
return (x >= 0 && y >= 0
&& x < Height && y < Width);
}
typedef struct
{
int x, y;
unsigned char reachable, sur, value;
} MapNode;
typedef struct Close
{
MapNode *cur;
char vis;
struct Close *from;
float F, G;
int H;
} Close;
typedef struct //���ȶ��У�Open��
{
int length; //��ǰ���еij���
Close* Array[MaxLength]; //��۽���ָ��
} Open;
static MapNode graph[Height][Width];
static int srcX, srcY, dstX, dstY; //��ʼ�㡢�յ�
static Close close[Height][Width];
// ���ȶ��л����
void initOpen(Open *q) //���ȶ��г�ʼ��
{
q->length = 0; // ����Ԫ�����ʼΪ0
}
void push(Open *q, Close cls[Height][Width], int x, int y, float g)
{ //�����ȶ��У�Open�������Ԫ��
Close *t;
int i, mintag;
cls[x][y].G = g; //����ӽڵ�����
cls[x][y].F = cls[x][y].G + cls[x][y].H;
q->Array[q->length++] = &(cls[x][y]);
mintag = q->length - 1;
for (i = 0; i < q->length - 1; i++)
{
if (q->Array[i]->F < q->Array[mintag]->F)
{
mintag = i;
}
}
t = q->Array[q->length - 1];
q->Array[q->length - 1] = q->Array[mintag];
q->Array[mintag] = t; //����ۺ���ֵ��С�ڵ����ڶ�ͷ
}
Close* shift(Open *q)
{
return q->Array[--q->length];
}
// ��ͼ��ʼ������
void initClose(Close cls[Height][Width], int sx, int sy, int dx, int dy)
{ // ��ͼClose���ʼ������
int i, j;
for (i = 0; i < Height; i++)
{
for (j = 0; j < Width; j++)
{
cls[i][j].cur = &graph[i][j]; // Close����ָ�ڵ�
cls[i][j].vis = !graph[i][j].reachable; // �Ƿ
0 0
- 456
- 456
- 456
- 456
- 456
- 456
- 456
- 456
- 456
- SRM 456
- 123,456
- 【NYOJ 456】
- Nyoj 456
- ocp-456
- nyoj 456
- 备用456
- 123我们456
- rqnoj 456 低价购买
- tjut 4655
- JavaEE程序猿的Java世界观⑤
- 元数据
- 内存分配:堆、栈、全局变量/静态变量、代码区
- PHP 相关知识点
- 456
- Spark on Yarn 图
- monolog文档解读
- centos 7安装jdk1.7等常用开发工具
- cookie,session专题2-1:springmvc中jsonp跨域的几种解决方案
- mysql中的外键
- linux用户登录时无法默认进入bash的解决办法
- JAVA WEB项目中,配置一个代替404错误页面
- 5-26 单词长度 (15分)
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
大丰房产网
大丰房产
大丰区
大丰港
大丰农场
大丰零距离
大丰门漂流
大丰镇
江苏大丰
大丰马拉松
大丰港旅游
成都大丰
大丰邮编
大丰市
大丰华高速
大丰麋鹿
大丰海景房
大丰招聘
中国大丰
大丰特产
大丰之声
大丰吧
大丰楼盘
大丰旅行社
大丰海洋馆
大丰 楼盘
大丰灯饰
大丰托儿所
大丰门景区
大丰租房网
大丰在哪里
余姚大丰
大丰三日游
大丰蛋糕房
菏泽大丰
大丰招聘网
大丰项目网
大丰别墅区
钟大丰
大丰招聘会
大丰软件园