急!求解一道java的面试题。


package demo;

public class Xunhuan {

    public static void main(String[] args) {

    /*
    在start方法内控制台打印输入以下内容

    01 02 03 04 05 06 07 08 09 10
    28 29 30 31 32 33 34 35 36 11
    27 48 49 50 51 52 53 54 37 12
    26 47 60 59 58 57 56 55 38 13
    25 46 45 44 43 42 41 40 39 14
    24 23 22 21 20 19 18 17 16 15

     */
        start(9, 8);
    }

    /**
     * @param row    行数
     * @param column 列数
     */
    private static void start(int row, int column) {


    }

}
    private void start(int row, int column) {
        final int[][] map = new int[row][column];
        int y = 0, x = 0, fillNum = 0, direction = 0;
        do {
            if (map[y][x] == 0) {
                map[y][x] = ++fillNum;
                continue;
            }
            while (true) {
                int newY = y + ((direction == 3) ? -1 : (direction & 1));
                int newX = x + ((direction == 2) ? -1 : (direction & 1) ^ 1);
                if (newX < column && newX >= 0 && newY >= 0 && newY < row && map[newY][newX] == 0) {
                    y = newY;
                    x = newX;
                    break;
                }
                direction = (direction + 1) & 3;

            }
        } while (fillNum < column * row);
        for (int i = 0; i < row; i++) {
            for (int j = 0; j < column; j++) {
                System.out.printf("%02d ", map[i][j]);
            }
            System.out.println();
        }

    }

这谁家的面试题