-
大小: 4KB文件類型: .cpp金幣: 1下載: 0 次發(fā)布日期: 2021-01-05
- 語(yǔ)言: C/C++
- 標(biāo)簽: 數(shù)據(jù)結(jié)構(gòu)??c語(yǔ)言??
資源簡(jiǎn)介
數(shù)據(jù)結(jié)構(gòu) c語(yǔ)言
do{
if(pass(curpos,a)){//當(dāng)前位置可通
footprint(a,curpos);//留下足跡;
e->ord=curstep;
e->seat=curpos;
e->di=1;
push(s,e);
if(curpos->seatx==end->seatx&&curpos->seaty==end->seaty)break;//到達(dá)終點(diǎn)(出口)
nextpos(curpos
代碼片段和文件信息
#include?
#include?
#define?SIS?100???//存儲(chǔ)空間初始分配量
#define?N?10??????//存儲(chǔ)空間分配增量
typedef?struct{
???int?seatx;
???int?seaty;
}sit;//當(dāng)前訪問(wèn)的坐標(biāo)
typedef?struct{
???int????ord;???????//通道塊在路徑上的“序號(hào)”
???sit????*seat;?????//通道塊在迷宮中的“坐標(biāo)位置”
???int????di;????????//從此通道塊走向下一通道塊的“方向”di為下個(gè)尋找的方向
}finds;
typedef?struct{
???finds??*base;
???finds??*top;
???int????size;
}stack;
void?initstack(stack?*s){
????finds?*link*end;
????s->base=s->top=link=(finds?*)malloc(SIS*sizeof(finds));
????end=link+SIS-1;
????for(;link<=end;link++)
????link->seat=(sit?*)malloc(sizeof(sit));
????s->size=SIS;
}//堆棧初始化
void?push(stack?*sfinds?*find){
????finds?*link*end;
????if(s->top-s->base>=s->size){
???????s->base=(finds?*)realloc(s->base(s->size+SIS)*sizeof(finds));
?????
評(píng)論
共有 條評(píng)論