#include <stdio.h>
#include "stack.h"
int map1[9][11]={
{0,0,1,1,0,1,1,0,1,1,1},
{0,1,0,0,0,1,0,0,0,1,0},
{0,1,1,0,1,0,0,0,1,0,0},
{0,0,0,0,1,0,1,0,0,1,0},
{0,1,0,1,0,0,0,1,0,0,0},
{0,1,0,1,0,1,1,1,1,1,0},
{1,0,0,0,0,0,0,1,0,0,0},
{0,0,1,1,1,1,1,1,0,1,1},
{1,0,0,0,0,0,0,1,0,0,0},
};
int map2[][9]={
{0,0,0,0,0,1,0,0,0},
{1,0,0,1,0,0,0,1,0},
};
int sx=0,sy=0;
int tx=8,ty=10;
//保存路径
void show(){
int i,j;
printf("--------------\n");
for(i=0;i<=tx;i++){
printf("|");
for(j=0;j<=ty;j++){
switch(map1[i][j]){
case -1:
case 0:printf(" ");break;
case 1:printf("#");break;
case 2:printf("*");break;
}
}
printf("|\n");
}
printf("--------------\n");
}
int walk(){
Stack s;
stack_init(&s,100);
T pos={sx,sy,N};
stack_push(&s,pos);
map1[0][0]=2;
int nx=0,ny=0;
enum FX dir=RIGHT;
用堆栈实现走迷宫
最新推荐文章于 2021-01-15 23:30:34 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)