五年前写的了。
代码不太规范。#include <stdio.h>
#include <dos.h>
#include <conio.h>
#include <malloc.h>
#include <process.h>
#include <bios.h>
#define  BAR     0X02
#define  CONNOR  0X03
#define  TITLE   0X01
#define  ENTER   0X05
#define  OUTDOOR 0X06#define  NONE    0X00
#define  FIRST   0X10
#define  SECOND  0X11#define  MAXSTEP 4000
void initmaze(int xx,int yy);
void write_char(int left,int top,char ch,int attribt);
char far *vseg=(char far *)MK_FP(0XB800,0000);
unsigned char maze_box[20][20]={   {  3,1,1,1,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3 },
   {  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
   {  2,1,1,1,3,1,0,1,1,1,1,1,1,1,3,1,1,0,1,2 },
   {  2,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,2 },
   {  2,0,2,0,3,1,1,1,1,1,1,1,0,1,3,1,1,3,0,2 },
{  2,0,2,0,2,0,0,0,0,0,0,0,0,0,2,0,0,2,0,2 },
{  2,0,2,0,3,1,0,1,1,1,1,3,1,3,3,3,0,2,0,2 },
{  2,0,2,0,2,0,0,0,0,0,0,2,0,3,3,3,0,0,0,2 },
{  2,0,2,0,3,1,1,1,1,1,0,3,0,0,0,2,0,3,1,2 },
{  2,0,2,0,0,0,0,0,0,0,0,3,1,1,0,2,0,2,0,2 },
{  2,0,3,1,1,1,1,1,1,1,1,3,0,0,0,0,0,2,0,2 },
{  2,0,0,0,0,0,0,0,0,0,0,3,1,3,1,1,0,2,0,2 },
{  2,1,1,1,1,1,1,1,0,3,1,3,0,2,0,0,0,2,0,2 },
{  2,0,0,0,0,0,0,0,0,2,0,2,0,2,0,2,0,2,0,2 },
{  2,1,1,1,1,1,1,1,1,3,0,0,0,0,0,2,0,0,0,2 },
{  2,0,0,0,2,0,0,0,3,2,0,1,1,1,1,3,1,1,1,2 },
{  2,0,2,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,2 },
{  2,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2 },
{  2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2 },
{  3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,6,1,1,3 },};
int ex=0;
int ey=0;
unsigned char *maze_stack;
int  stack_sp;void search_enter(void);
int begin_enter(int xx,int yy);
void push_stack(int xx,int yy);
void pop_stack(int *xx,int *yy);void main()
{
     int x;
     clrscr();
     initmaze(1,1);
     search_enter();
     if(ex==0&&ey==0){
printf("Not search enter .\n");
return;
     }
     maze_stack=(char *)malloc(MAXSTEP);
     if(maze_stack==NULL){
 printf("Not enough memory!");
 return;
     }
     stack_sp=0;
     if(begin_enter(1,1)){
  printf("Sucessfully to out\n");
  getch();
  clrscr();
  printf("He is step is :\n");
  for(x=0;x<stack_sp;x+=2)
     printf("%2d -> x = %2d,y = %2d\n",x/2,maze_stack[x],maze_stack[x+1]);
     }
     else 
  printf("Failed to out\n");
     getch();
     free(maze_stack);
     return;
}
void initmaze(int xx,int yy)
{
    int x,y;
    for(y=0;y<20;y++){
       for(x=0;x<20;x++){
  if(maze_box[y][x]==TITLE)write_char(x*2+xx,y+yy,'- ',0x03);
  if(maze_box[y][x]==BAR) write_char(x*2+xx,y+yy,'| ',0x03);
  if(maze_box[y][x]==CONNOR)write_char(x*2+xx,y+yy,'+ ',0x03);
  if(maze_box[y][x]==ENTER)write_char(x*2+xx,y+yy,' ',0x03);
  if(maze_box[y][x]==OUTDOOR)write_char(x*2+xx,y+yy,' ',0x03);
       }
    }
    return;
}
void push_stack(int xx,int yy)
{
    if(stack_sp+2>=MAXSTEP){
       printf("I'm lost a way.\n");
       exit(0);
    }
    maze_stack[stack_sp] = (char)xx;
    stack_sp++;
    maze_stack[stack_sp] = (char)yy;
    stack_sp++;
    return;
}void pop_stack(int *xx,int *yy)
{
     if(!stack_sp)return;
     stack_sp--;
     *yy=maze_stack[stack_sp];
     stack_sp--;
     *xx=maze_stack[stack_sp];
     return;
}int begin_enter(int xx,int yy)
{
    int lx,ly,a=0;
    if(ex==0&&ey==0)return 0;
    lx=ex;
    ly=ey;
    push_stack(lx,ly);
    maze_box[ly][lx]=SECOND;
    while(1){
 if(bioskey(1))
    if(bioskey(0)==0x3920)exit(0);
 write_char(lx*2+xx,ly+yy,'M',0x04);
 delay(100);  if(maze_box[ly+1][lx]==OUTDOOR){
     write_char(lx*2+xx,ly+yy,' ',0x04);
     ly++;
     push_stack(lx,ly);
     write_char(lx*2+xx,ly+yy,'M',0x04);
     return 1;
 }
 if(maze_box[ly-1][lx]==OUTDOOR){
     write_char(lx*2+xx,ly+yy,' ',0x04);
     ly--;
     push_stack(lx,ly);
     write_char(lx*2+xx,ly+yy,'M',0x04);
     return 1;
 }
 if(maze_box[ly][lx+1]==OUTDOOR){
     write_char(lx*2+xx,ly+yy,' ',0x04);
     lx++;
     push_stack(lx,ly);
     write_char(lx*2+xx,ly+yy,'M',0x04);
     return 1;
 }
 if(maze_box[ly][lx-1]==OUTDOOR){
     write_char(lx*2+xx,ly+yy,' ',0x04);
     lx--;
     push_stack(lx,ly);
     write_char(lx*2+xx,ly+yy,'M',0x04);
     return 1;
 }  if(lx==ex&&ly==ey&&a)
      return 0;  a=1;
 if(ly<19&&maze_box[ly+1][lx]==NONE){
maze_box[ly][lx]=FIRST;
write_char(lx*2+xx,ly+yy,' ',0x04);
ly++;
push_stack(lx,ly);
continue;
 }
 if(ly>0&&maze_box[ly-1][lx]==NONE){
maze_box[ly][lx]=FIRST;
write_char(lx*2+xx,ly+yy,' ',0x04);
ly--;
push_stack(lx,ly);
continue;
 }
 if(lx<19&&maze_box[ly][lx+1]==NONE){
maze_box[ly][lx]=FIRST;
write_char(lx*2+xx,ly+yy,' ',0x04);
lx++;
push_stack(lx,ly);
continue;
 }
 if(lx>0&&maze_box[ly][lx-1]==NONE){
maze_box[ly][lx]=FIRST;
write_char(lx*2+xx,ly+yy,' ',0x04);
lx--;
push_stack(lx,ly);
continue;
 }
 maze_box[ly][lx]=SECOND;
 write_char(lx*2+xx,ly+yy,' ',0x04);
 pop_stack(&lx,&ly);
    }
}void search_enter()
{
     int x,y;
     for(x=1;x<19;x++){
if(maze_box[0][x]==ENTER){
    ex=x;
    ey=0;
    return;
}
if(maze_box[19][x]==ENTER){
    ex=x;
    ey=19;
    return;
}
     }
     for(y=1;y<19;y++){
if(maze_box[y][0]==ENTER){
     ex=0;
     ey=y;
     return;
}
if(maze_box[y][19]==ENTER){
     ex=19;
     ey=y;
     return;
}
     }
     ex=0;
     ey=0;
     return;
}
void write_char(int left,int top,char ch,int attribt)
{
    char far *ss;
    ss=vseg+top*80*2+left*2;
    *ss++=ch;
    *ss++=(char)attribt;
    return;
}