迷宫求解数据结构C语言版.doc

想预览更多内容,点击预览全文

申明敬告:

本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己完全接受本站规则且自行承担所有风险,本站不退款、不进行额外附加服务;如果您已付费下载过本站文档,您可以点击这里二次下载

文档介绍

PAGE / NUMPAGES

#include <stdio.h>

#include <stdlib.h>

#include <malloc.h>

#define STACK_INIT_SIZE 100

#define STACKINCREMENT 10

typedef struct{ int r; int c;

}PosType;//通道块坐标

typedef struct { int ord;//通道块在路径上的序号 PosType seat;//通道块的坐标位置 int di;//下一个探索的方向

}SelemType;

typedef struct { int r; int c; char adr[10][10];

}MazeType;//迷宫行列,内容

typedef struct { SelemType * base; SelemType * top; int stacksize;

}SqStack;

void InitStack(SqStack &S)

{ S.base=(SelemType*)malloc(STACK_INIT_SIZE * sizeof(SelemType)); if(!S.base) exit(0); S.top=S.base; S.stacksize=STACK_INIT_SIZE;

}

void Push(SqStack &S,SelemType &e)

{ if((S.top-S.base)>=S.stacksize) { S.base=(SelemType*)realloc(S.base,(S.stacksize+STACKINCREMENT)* sizeof(SelemType)); if(!S.base) exit(0); S.top=S.base+S.sta

最近下载