
本文共 3079 字,大约阅读时间需要 10 分钟。
������������
������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������
������������������������������������������������������������������������������������������������������������������������������������������������������1���������������������������������0���������������������������������������������������������������map[3][1]
���map[3][2]
������������������������������������������������
������������������������������������������
public class MiGong { public static void main(String[] args) { int[][] map = new int[8][7]; for(int i = 0; i < 7; i++) { map[0][i] = 1; map[7][i] = 1; } for (int j = 0; j < 8; j++) { map[j][0] = 1; map[j][6] = 1; } map[3][1] = 1; map[3][2] = 1; // ���������������...
������������
������������������������������������������������
1 1 1 1 1 1 11 0 0 0 0 0 11 0 0 0 0 0 11 1 1 1 1 1 1...
������������������
���������������������������������������������������������������setWay
������������������������������������������������true������������������������false���������������
���������������������
map[6][5] == 2
������������true���map[i][j] != 0
������������false���public class MiGong { public static void main(String[] args) { int[][] map = new int[8][7]; // ������������������... boolean b = setWay(map, 1, 1); // ������������������... } public static boolean setWay(int[][] map, int i, int j) { if (map[6][5] == 2) { return true; } else { if (map[i][j] == 0) { map[i][j] = 2; if (setWay(map, i + 1, j)) return true; if (setWay(map, i, j + 1)) return true; if (setWay(map, i - 1, j)) return true; if (setWay(map, i, j - 1)) return true; map[i][j] = 3; return false; } else { return false; } } }}
������������
���������������������������������������������������������������������������������������������������b
������true������������b
���false���
������������
���������������������������������������������������������������������������������������������������������������������������������������2������������������false���
���������������������1 1 1 1 1 1 11 2 2 2 2 2 11 2 2 2 2 2 11 1 1 1 1 1 1...true
������
������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
