哪位高手帮小弟我把这个有关问题了结,给你最大值100分!MAZE,不要大道理,只要这段代码的异常,多谢

谁帮我把这个问题了结,给你最大值100分!!!!!MAZE,不要大道理,只要这段代码的错误,谢谢!
哪位高手帮小弟我把这个有关问题了结,给你最大值100分!MAZE,不要大道理,只要这段代码的异常,多谢哪位高手帮小弟我把这个有关问题了结,给你最大值100分!MAZE,不要大道理,只要这段代码的异常,多谢哪位高手帮小弟我把这个有关问题了结,给你最大值100分!MAZE,不要大道理,只要这段代码的异常,多谢

PS:有一个未结的贴是就是同一个问题,没人解决。还有我问过老师,她没有给我明确的答复,渣渣。
问题:不能输出迷宫路径,直接输出没有路径,stack.h应该是没问题的,问题可能出在do……while循环之中

//stack.h
#ifndef _STACK_H_//当有多个头文件时用到,防止重定义
#define _STACK_H_
#include<iostream>
#include<stdlib.h>

const int SIZE = 81;
using namespace std;

typedef struct
{
int x;
int y;
}PosType;
typedef struct SElemType{//栈数据信息
int ord;//步数
PosType seat;//坐标
int di;//方向,1,2,3,4分别代表东南西北
}SElemType;
typedef struct SqStack{//栈结构
SElemType *base;//栈底指针
SElemType *top;//栈顶指针
int StackSize;
}SqStack;

void Init_S(SqStack &S)//初始化栈
{
S.base = new SElemType[SIZE];//给栈分配空间
if(!S.base)//判断分配空间是否成功
exit(EXIT_FAILURE);
S.top = S.base;//使栈为空
S.StackSize = SIZE;//栈大小
}
bool StackEmpty(SqStack S)//判断栈是否为空
{
if(S.top == S.base)
return true;
return false;
}
void Push(SqStack &S,SElemType e)//按FILO将数据入栈
{
SElemType *newbase;
if(S.top-S.base>=S.StackSize)//判断栈是否已满
{
newbase = new SElemType[S.StackSize*2];//是则重新分配空间
if(!S.base)
exit(EXIT_FAILURE);
for(int i(0);i<S.top-S.base;i++)//将以前的栈数据赋给新栈
*(newbase+i) = *(S.base+i);
delete[]S.base;
S.base = newbase;
S.top = S.base+S.StackSize;
S.StackSize *= 2;
}
*(S.top)++ = e;
}

SElemType Get_top(SqStack S)
{
if(!StackEmpty(S))
return *(S.top-1);
}
void Pop(SqStack &S,SElemType e)//按FILO出栈数据
{
if(StackEmpty(S))//栈为空则无法弹出数据
cout<<"empty stack!\n";
else
e = *(--S.top);
}
#endif

//maze_path.cpp
#include<iostream>
#include<cstdlib>
#include<fstream>
#include"stack.h"
using namespace std;
const int m = 10;
const int n = 10;//在此定义迷宫数组的行及列的大小
typedef char MazeG[m][n];

void Show_MG(MazeG MG)//输出MG数组
{

for(int i(0);i<m;i++)
{
for(int j(0);j<n;j++)
{
cout<<MG[i][j];
}
cout<<"\t\n";
}
}
PosType Next(PosType &pos,int di)
{
PosType repos;
switch(di)//逆时针方向
{
case 0://北
repos.x = pos.x-1;
repos.y = pos.y;
break;
case 1://东
repos.x = pos.x;
repos.y = pos.y+1;
break;
case 2://南
repos.x = pos.x+1;
repos.y = pos.y;
break;
case 3://西
repos.x = pos.x;
repos.y = pos.y-1;
break;
default:
break;
}
return repos;
}

bool MazePath(MazeG &MG,PosType begin,PosType end)
{
PosType curpos = begin;//将开始位置设为当前位置
SqStack S; 
Init_S(S);
SElemType e;
e.ord = 0;//初始步数
e.di = 0;//初始方向
    do{
if(MG[curpos.x][curpos.y]=='*')//判断当前位置是否可行,字符为*则可通过
{
MG[curpos.x][curpos.y] = '+';//留下足迹+
e.seat = curpos;
e.ord++;//步数增加
Push(S,e);//将当前位置存入栈数据
if(curpos.x==end.x&&curpos.y==end.y)
{
cout<<"此迷宫的一条路径如下:(+标记为路径)\n";
cout<<"走了"<<e.di<<"步到达出口\n";
Show_MG(MG);
return true;
}
else//没到终点
curpos = Next(e.seat,e.di);//向下一个位置探寻
}
else//不能通过
if(!StackEmpty(S))
{
Pop(S,e);//是墙,退栈
e = Get_top(S);
e.ord--;
while(e.di==3&&!StackEmpty(S))//走完所有方向,是死角
{
MG[curpos.x][curpos.y] = '#';//将此位置标记为墙
Pop(S,e);//退栈
e = Get_top(S);
e.ord--;
}
if(e.di<3)//没走完所有方向
{
e.di++;//下一个方向
Push(S,e);
e.ord++;
curpos = Next(e.seat,e.di);//确定当前位置
}
}
}while(StackEmpty(S));
cout<<"警告:此迷宫没有入口到出口的路径!!!! ! !!!!\n";
return false;
}

int main()
{
MazeG MG;
PosType begin,end;
begin.x = 1; begin.y = 1;//开始坐标
end.x = 8; end.y = 8;//终点坐标

ifstream fin;//从文本文件读取迷宫图
fin.open("file.txt");//打开存放迷宫数据的文件
if(!fin.is_open())//检测文本文件是否能打开
{
cout<<"erorr file!!\n";
exit(EXIT_FAILURE);
}
if(fin.good())//文本文件能打开则读取迷宫图
{
for(int i(0);i<m;i++)
for(int j(0);j<n;j++)
fin>>MG[i][j];
}
cout<<"迷宫图为:(*代表能通过)\n";
Show_MG(MG);
//fin>>begin.x>>begin.y;
//fin>>end.x>>end.y;
fin.close();//关闭文件
cout<<"开始坐标:("<<begin.x<<","<<begin.y<<")\n终点坐标:("<<end.x<<","<<end.y<<")"<<endl;