题目不解释,直接上代码:
/**
* Created by xukaifang on 16/9/9.
*/
import java.util.*;
public class Main {
private static int[][] map = null;
private static List<Node> openList = new ArrayList<Node>();// 开启列表
private static List<Node> closeList = new ArrayList<Node>();// 关闭列表
private static List<Node> resultList = new ArrayList<Node>();// 结果列表
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String lines=sc.nextLine();
String[] linesStr=lines.split(" ");
int length=linesStr.length;
int[][] map1=new int[length][length];
for(int i=0;i<length;i++){
map1[0][i]=Integer.parseInt(linesStr[i]);
}
for(int i=1;i<length;i++){
String tmpLines=sc.nextLine();
String[] tmpLinesStr=tmpLines.split(" ");
for(int j=0;j<length;j++){
map1[i][j]=Integer.parseInt(tmpLinesStr[j]);
}
}
// 1代表通路、0代表障碍-----矩阵的邻接表方式记录图
/*map = new int[][] {// 地图数组
{ 0, 1, 0, 0},
{ 0, 0, 0, 1},
{ 1, 0, 1, 0},
{ 0, 0, 0, 0}};*/
map=map1;
int Max_row = map.length;
int MAX_col = map[0].length;
Node startPoint = new Main().new Node(0, 0, null);
Node endPoint = new Main().new Node(Max_row - 1,
MAX_col - 1,