日期:2014-05-18 浏览次数:21071 次
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
public struct Postion
{
public int X;
public int Y;
public Postion(int X, int Y)
{
this.X = X;
this.Y = Y;
}
};
class Program
{
static int[,] maze = new int[10, 10] {{ 0, 0, 0, 0,-1, 0, 0, 0, 0, 0},
{ 0,-1,-1, 0, 0, 0, 0,-1, 0, 0},
{ 0, 0,-1, 0,-1, 0, 0,-1, 0,-1},
{ 0, 0,-1, 0,-1, 0, 0,-1, 0,-1},
{ 0, 0, 0, 0,-1,-1, 0,-1, 0, 0},
{ 0, 0,-1, 0, 0, 0, 0, 0, 0, 0},
{ 0,-1, 0, 0,-1, 0,-1,-1, 0, 0},
{ 0, 0, 0,-1, 0, 0, 0,-1, 0,-1},
{-1, 0, 0,-1, 0, 0, 0,-1, 0,-1},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0,-1}
};
static void printPath(Stack<Postion> path)//打印路径没用的
{
/* while (!path.empty())
{
printf("[%d][%d] ==>> [%2d]\n",
path.top().X, path.top().Y,
maze[path.top().X][path.top().Y]-1);
path.pop();
}*/
System.Console.Write(path.Count);
}
/* static void printMat(int mat[10,10])//打印地图没用的
{
for (int i = 0; i < 10 ; i++)
{
for (int j = 0; j < 10 ; j++)
{
printf("%2d ", mat[i][j]);
}
printf("\n");
}
}
*/
//开始用用的
static bool isCanGo(int prePosValue,
int posX,
int posY)
{
if (posX < 0
}
if (path.Count< stackpath.Count || stackpath.Count == 0) // 更短的路径
stackpath = new Stack<Postion>(path);
return;