输入: 5 6 ....S* .**... .*..*. *..**. .T.... 输出: 7 import java.util.*; public class LANQIAO1 { public static int n; // 行 public static int m; // 列 public static String[] tmp = new String[110]; // 字符串数组用于给字符数组赋值 public static char[][] maze = new char[110][110]; public static boolean[][] vis = new boolean[110][110]; // 方向数组(x,y 的增量)(逆时针),用于给当前位置加数表示从当前位置,往上 左 下 右 移动 public static int[][] dir = { {-1,0},{0,-1},{1,0},{0,1}}; public static boolean f; public static int ans = 1000000000; // 判断当前位置是否合法(在迷宫数组中没有越界) public static boolean in(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; } // 返回能不能走出去 public static void dfs(int x ,int y, int step){ if(maze[x][y] == 'T'){ if(step < ans){ ans = step; }