C语言蛮力法解决迷宫问题

//迷宫问题解法2


#include 
#define MAXQ 100								//队列大小
#define MAxN 10									//最大迷宫大小
//问题表示
int n=8;
																		
char Maze[MAxN][MAxN]={							//迷宫大小
		{'O','x','x','x','x','x','x','x'},
		{'O','O','O','O','O','x','x','x'},
		{'x','O','x','x','O','O','O','x'},
		{'x','O','x','x','O','x','x','O'},
		{'x','O','x','x','x','x','x','x'},
		{'x','O','x','x','O','O','O','x'},
		{'x','O','O','O','O','x','O','O'},
		{'x','x','x','x','x','x','x','O'}
};
int H[4]={0,1,0,-1};								//水平偏移量,下标对应方位号0~3
int V[4]={-1,0,1,0};								//垂直偏移量
struct Position										//队列元素类型
{
	int x,y;										//当前方块位置
	int pre;										//前驱方块的下标
};
	
Position qu[MAXQ];									//定义一个队列qu
int front=-1,rear=-1;								//定义队头和队尾						

void disppath(int front)							//输出一条迷宫路径
{	int i,j;
	for(i=0;i=0 && p2.y>=0 && p2.x

你可能感兴趣的:(C语言)