/*
*Copyright (c) 2016, 烟台大学计算机学院
*All rights reserved.
*文件名称:main.cpp
*作者:张旺华
*完成日期: 2016 年 7 月 1 日
*版本号:v1.0
*问题描述:编写一个求解迷宫问题
*
*/
#include <stdio.h>
#include <malloc.h>
#define MaxSize 100
#define N 4 //列号
#define M 4 //行号
int mg[M+2][N+2]={ //一个迷宫,其四周要加上均为1的外框
{1,1,1,1,1,1},
{1,0,0,0,1,1},
{1,0,1,0,0,1},
{1,0,0,0,1,1},
{1,1,0,0,0,1},
{1,1,1,1,1,1}
};
struct
{
int i,j;
int di;
}Stack[MaxSize],Path[MaxSize]; //定义栈和存放最短路径的数组
int top=-1; //栈顶指针
int count=1; //路径数计数
int minlen=MaxSize; //最短路径长度
void mgpath(int xi,int yi,int xe,int ye) //求解迷宫
{
int i,j,di,find,k;
top++; //进栈
Stack[top].i=xi;
Stack[top].j=yi;
Stack[top].
栈 求解迷宫
最新推荐文章于 2023-12-14 14:04:02 发布