迷宫游戏
方法一(DFS):
#include <stdio.h>
int min=999;
int m,n,p,q;
int a[51][51],book[51][51];
void DFS(int x,int y,int step)
{
int next[4][2]={
{
0,1},{
1,0},{
0,-1},{
-1,0}};
int tx,ty,k;
if(x==p&&y==q)
{
if(step<min)min=step;
return ;
}
for(k=0;k<4;k++)
{
tx=x+next[k][0];
ty=y+next[k]