亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? knightboard.java

?? 設計一個軟件的啟動過程界面
?? JAVA
字號:
/** A variable-size chess board that supports finding a complete    tour, or Hamiltonian cycle, for the knight on the board.    The dimensions (width and height) of the board may be specified,    but must be at least five. Individual squares are referenced by    their x and y indices, the first one being (0, 0). <P>    Note: subclasses Canvas only to emulate multiple inheritance for    GraphicalBoard.    @see GraphicalBoard    @see KnightThread*/public class KnightBoard extends java.awt.Canvas {    /** Value of the starting square as returned by getValue().        Greater than any other valid weight values.        @see #getValue    */    public static final int STARTSQUARE = Integer.MAX_VALUE;    /** Minimum width and height of the board in squares. */    public static final int MIN_DIMENSION = 5;    /** Width of the board in squares. */    public final int width;    /** Height of the board in squares. */    public final int height;    private int[][] value;              // Value of square    private int[][] move;               // Number of move    private final boolean[][] wayback;  // Is adjacent to start square?    private final int[][][][] adjlist;  // Adjacency list    private int waysback = 0;    private int nummoves = 0;    /** Constructs a board of the specified size.        @param width width of the board in squares.        @param height height of the board in squares.    */    public KnightBoard(int width, int height) {        if (width < MIN_DIMENSION || height < MIN_DIMENSION)            throw new RuntimeException("board dimension too small");        this.width = width;        this.height = height;        move = new int[width][height];        wayback = new boolean[width][height];        adjlist = new int[width][height][9][2];        value = new int[width][height];        initBoard();    }    /** Sets the first (and last) square of the tour. The square is marked        reserved - its value becomes STARTSQUARE, but the knight is not        actually moved to it. The intent is to move to this square as the        last step that completes the tour.        @param x x-index of start square.        @param y y-index of start square.        @return true if OK, false if start square already set.        @see #STARTSQUARE    */    public boolean setStartSquare(int x, int y) {        if (nummoves == 0 && waysback == 0) {            value[x][y] = STARTSQUARE;            for (int i = 0; adjlist[x][y][i][0] >= 0; ++i) {                int jx = adjlist[x][y][i][0];                int jy = adjlist[x][y][i][1];                wayback[jx][jy] = true;                ++waysback;            }            return true;        } else            return false;    }    /** Moves the knight to the specified square, updating adjacent values.        Also checks for possibly resulting unreachable squares.        @param x x-index of the square to move to.        @param y y-index of the square to move to.        @return true if successful; false if unreachable squares resulted,        in which case the move should probably be undone.                @see #undoMove    */    public boolean moveKnight(int x, int y) {        move[x][y] = ++nummoves;        if (wayback[x][y])            --waysback;        if (!changeAdjacentValues(x, y, -1))            return false;        if (waysback == 0 && !isFinished(x, y))            return false;        return true;    }    /** Undoes the move to the specified square, updating adjacent values.        If the cancelled move is not the most recent one, the result is        undefined.        @param x x-index of the knight.        @param y y-index of the knight.        @see #moveKnight    */    public void undoMove(int x, int y) {        --nummoves;        move[x][y] = 0;        changeAdjacentValues(x, y, 1);        if (wayback[x][y])            ++waysback;    }    /** Returns the number of moves done thus far.        @return number of moves.    */    public int getNumMoves() {        return nummoves;    }    /** Returns the value of the specified square. The value is the number of        exits, ie. unvisited squares currently reachable from the specified one.        @param x x-index of square.        @param y y-index of square.        @return value of the square.    */    public int getValue(int x, int y) {        return value[x][y];    }    /** Similar to getValue() but with range checking.        @param x x-index of square.        @param y y-index of square.        @return value of the square or Integer.MIN_VALUE if index out of range.        @see #getValue    */    public int getValueAt(int x, int y) {        if (x >= 0 && x < width && y >= 0 && y < height)            return value[x][y];        else            return Integer.MIN_VALUE;    }    /** Returns the number of the move that visited the specified square.        @param x x-index of square.        @param y y-index of square.        @return number of move, zero if unvisited.    */    public int getMove(int x, int y) {        return move[x][y];    }    /** Returns an adjacency list, or rather an array, of the squares        reachable directly from the specified one. The return value        is a reference - the contents of the array may not be changed!        @param x x-index of square.        @param y y-index of square.        @return reference to a two-dimensional array of size [9][2].        The first index enumerates the adjacent squares; 0 and 1        in the second correspond to their x and y coordinates. The list        is terminated with negative coordinates.    */    public int[][] getAdjacencyList(int x, int y) {        return adjlist[x][y];    }    /** Checks if the specified square is next-to-last in the tour.        If it is, the tour can be completed by moving the knight        to the start square.    */    public boolean isFinished(int x, int y) {        if (nummoves == width*height - 1 && move[x][y] == nummoves && wayback[x][y])            return true;        else            return false;    }    /** Returns the number of unvisited squares reachable directly from        the start square; in other words, the number of ways back to it.        If the return value is zero, but the tour is not finished, the        start square is unreachable and the tour is impossible to complete.        @return number of unvisited squares adjacent to the start square.    */    public int getWaysBack() {        return waysback;    }    /** A quite complete invariant test for the KnightBoard class. Checks        the validity of the various parameters and squares of the board.        Useful for debugging and testing purposes.        @return true if the board is valid; false means a serious bug!    */    public boolean Invariant() {        if (nummoves < 0 || nummoves > width*height)            return false;        if (value == null || move == null || wayback == null || adjlist == null)            return false;        int moves_count = 0, wayback_count = 0, max_move = 0;        int startx = -1, starty = -1;        // Go through all squares, count number of moves and ways back        for (int y = 0; y < height; ++y) {            for (int x = 0; x < width; ++x) {                int this_value = 0;                // There should be only one start square                if (value[x][y] == STARTSQUARE) {                    if (wayback_count != 0)                        return false;                    if (move[x][y] != 0 && move[x][y] != width*height)                        return false;                    startx = x;                    starty = y;                }                if (value[x][y] < 0 || move[x][y] < 0)                    return false;                if (move[x][y] > 0) {                    ++moves_count;                    max_move = (move[x][y] > max_move) ? move[x][y] : max_move;                }                // Go through the adjacency list, calculate value                int i;                for (i = 0; adjlist[x][y][i][0] >= 0; ++i) {                    int jx = adjlist[x][y][i][0];                    int jy = adjlist[x][y][i][1];                                        if (move[jx][jy] == 0)                        ++this_value;                    // Do we have wayback[]s in right places?                    if (value[x][y] == STARTSQUARE && move[jx][jy] == 0) {                        if (!wayback[jx][jy])                            return false;                        ++wayback_count;                    }                }                // At least one neighbor                if (i < 1)                    return false;                // Does the calculated value match?                if (value[x][y] != STARTSQUARE && this_value != value[x][y])                    return false;            }        }        // Do the number of moves and ways back match?        if (moves_count != nummoves || max_move != nummoves || wayback_count != waysback)            return false;            // If the tour is not finished, stop here        if (nummoves < width*height)            return true;        // Check that all steps are adjacent and in correct order        int x = startx, y = starty;        for (int n = 1; n <= nummoves; ++n) {            boolean found = false;            for (int i = 0; adjlist[x][y][i][0] >= 0; ++i) {                int jx = adjlist[x][y][i][0];                int jy = adjlist[x][y][i][1];                if (move[jx][jy] == n) {                    found = true;                    x = jx;                    y = jy;                    break;                }            }            if (!found)                return false;        }        // All checked!        return true;    }    /** Changes the values of the squares adjacent to the specified one        by the offset. If the change results in either          1) unvisited squares with value zero, or          2) wayback-squares with value one,        false is returned, as those squares are unreachable!        @param x x-index of square.        @param y y-index of square.        @param offset the value to be added to the adjacent squares.        @see #getWaysBack    */    private boolean changeAdjacentValues(int x, int y, int offset) {        boolean orphans = false;        for (int i = 0; adjlist[x][y][i][0] >= 0; ++i) {            int jx = adjlist[x][y][i][0];            int jy = adjlist[x][y][i][1];                        if (value[jx][jy] != STARTSQUARE) {                if (((value[jx][jy] += offset) == 0 && move[jx][jy] == 0) ||                    (wayback[jx][jy] && move[jx][jy] == 0 &&                     value[jx][jy] == 1 && nummoves < width*height - 2))                    orphans = true;            }        }        return !orphans;    }    /** Initializes the board, computing the adjacency list and value        for each square in the board. Called from the constructor.        @see #getAdjacencyList        @see #getValue    */    private void initBoard() {        for (int y = 0; y < height; ++y) {            for (int x = 0; x < width; ++x) {                int i = 0;                if (getValueAt(x - 2, y - 1) >= 0) {                    adjlist[x][y][i][0] = x - 2; adjlist[x][y][i++][1] = y - 1; }                if (getValueAt(x + 2, y - 1) >= 0) {                    adjlist[x][y][i][0] = x + 2; adjlist[x][y][i++][1] = y - 1; }                if (getValueAt(x - 2, y + 1) >= 0) {                    adjlist[x][y][i][0] = x - 2; adjlist[x][y][i++][1] = y + 1; }                if (getValueAt(x + 2, y + 1) >= 0) {                    adjlist[x][y][i][0] = x + 2; adjlist[x][y][i++][1] = y + 1; }                if (getValueAt(x - 1, y - 2) >= 0) {                    adjlist[x][y][i][0] = x - 1; adjlist[x][y][i++][1] = y - 2; }                if (getValueAt(x + 1, y - 2) >= 0) {                    adjlist[x][y][i][0] = x + 1; adjlist[x][y][i++][1] = y - 2; }                if (getValueAt(x - 1, y + 2) >= 0) {                    adjlist[x][y][i][0] = x - 1; adjlist[x][y][i++][1] = y + 2; }                if (getValueAt(x + 1, y + 2) >= 0) {                    adjlist[x][y][i][0] = x + 1; adjlist[x][y][i++][1] = y + 2; }                adjlist[x][y][i][0] = adjlist[x][y][i][1] = -1;                  value[x][y] = i;            }        }    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩卡一卡二| 中文字幕一区二区三区乱码在线| 国产午夜精品久久久久久免费视 | 91精品国产综合久久精品| 精品99一区二区| 亚洲精品国产品国语在线app| 午夜伦理一区二区| av中文字幕亚洲| 久久综合一区二区| 天天综合色天天综合| 色婷婷综合久久久久中文一区二区| 精品成人a区在线观看| 一个色综合网站| 懂色av一区二区三区免费看| 欧美va亚洲va| 亚洲va欧美va人人爽| av中文字幕亚洲| 国产女人18水真多18精品一级做 | 亚洲女与黑人做爰| 成人性生交大片免费看中文| 欧美一区二区三区四区五区| 一区二区欧美精品| 成人h动漫精品一区二区| 久久综合av免费| 日韩电影在线免费看| 欧美日韩在线播放| 亚洲一区视频在线观看视频| 91视频免费播放| 中文字幕在线不卡| 不卡电影一区二区三区| 欧美国产禁国产网站cc| 国内精品国产三级国产a久久| 欧美一区二区日韩一区二区| 日韩制服丝袜先锋影音| 欧美喷潮久久久xxxxx| 亚洲成人动漫在线免费观看| 精品视频在线看| 偷窥国产亚洲免费视频| 欧美精品一级二级| 日韩黄色免费网站| 日韩欧美国产小视频| 老鸭窝一区二区久久精品| 日韩一区二区不卡| 国内成人精品2018免费看| 欧美大尺度电影在线| 久久不见久久见免费视频7| 精品国产99国产精品| 国产成人在线免费观看| 国产精品欧美综合在线| 成人免费视频caoporn| 亚洲欧美日韩中文字幕一区二区三区| 日本高清不卡一区| 日韩va欧美va亚洲va久久| 久久综合中文字幕| 成人国产精品免费网站| 亚洲国产成人av网| 337p日本欧洲亚洲大胆色噜噜| 国产一区二区免费视频| 1000部国产精品成人观看| 欧美亚日韩国产aⅴ精品中极品| 亚洲成人综合在线| 久久久三级国产网站| 色婷婷精品大在线视频| 五月婷婷久久丁香| 国产欧美一区二区三区在线看蜜臀| 97精品国产97久久久久久久久久久久| 亚洲一区二区三区精品在线| 日韩一区二区电影在线| 成人毛片老司机大片| 午夜久久久久久久久| 国产丝袜欧美中文另类| 欧美日韩在线播放三区| 丁香婷婷综合激情五月色| 亚洲一区在线观看免费观看电影高清| 精品少妇一区二区三区免费观看| 成人av小说网| 久久国产精品露脸对白| 18欧美亚洲精品| 日韩一级免费观看| 一本一道综合狠狠老| 激情图片小说一区| 亚洲最大的成人av| 国产精品少妇自拍| 日韩精品一区二区三区在线播放 | 国产精品剧情在线亚洲| 91精品国产综合久久久蜜臀粉嫩 | 一区二区在线观看视频| 久久精品视频网| 7777精品伊人久久久大香线蕉的 | 亚洲美女精品一区| 精品处破学生在线二十三| 欧美偷拍一区二区| 99久久精品免费看| 国产成人小视频| 精品一区二区三区视频| 亚洲成人动漫精品| 亚洲综合精品久久| 亚洲人成在线播放网站岛国| 久久理论电影网| 日韩精品一区二区三区中文精品| 欧美亚一区二区| 一本一本大道香蕉久在线精品| 成人免费毛片aaaaa**| 国产一区欧美日韩| 狠狠色狠狠色合久久伊人| 日韩激情一区二区| 日韩va亚洲va欧美va久久| 亚洲国产精品影院| 一区二区不卡在线播放| 一区二区三区日韩在线观看| 亚洲欧洲一区二区三区| 国产精品久久网站| 国产精品欧美一区喷水| 国产精品你懂的在线| 亚洲国产激情av| 国产精品乱码妇女bbbb| 国产欧美一区视频| 国产精品私人影院| 中文字幕在线免费不卡| 《视频一区视频二区| 最新中文字幕一区二区三区| 亚洲欧洲精品天堂一级| 亚洲欧美在线观看| 1000部国产精品成人观看| 日韩毛片高清在线播放| 一区二区三区中文字幕电影| 亚洲精品写真福利| 亚洲成人777| 欧美a级理论片| 精品一区二区三区免费| 国产一区二区伦理| eeuss国产一区二区三区| 色婷婷国产精品综合在线观看| 欧洲精品在线观看| 欧美一区二区三区免费在线看| 日韩视频中午一区| 久久久99久久| 亚洲男同性恋视频| 日日欢夜夜爽一区| 国产美女主播视频一区| 色综合久久久久综合体桃花网| 欧美三级一区二区| 久久综合九色综合欧美就去吻| 国产日韩欧美麻豆| 亚洲美女视频在线| 久久精品理论片| www.欧美精品一二区| 欧美色图激情小说| 久久亚洲二区三区| 一区二区三区四区av| 蜜臂av日日欢夜夜爽一区| 成人小视频免费在线观看| 欧美日韩在线播放三区| 久久精品在线观看| 亚洲成人资源网| 国产精品一级黄| 在线亚洲高清视频| 久久天天做天天爱综合色| 亚洲精品国久久99热| 精品一区二区三区免费毛片爱| 91亚洲精品一区二区乱码| 欧美一级高清片在线观看| 国产精品美日韩| 蜜臀av一级做a爰片久久| 91在线一区二区| 精品国产一区二区在线观看| 亚洲乱码国产乱码精品精可以看| 国产一区二区三区在线观看免费视频 | 26uuu亚洲| 亚洲一卡二卡三卡四卡五卡| 国产传媒欧美日韩成人| 欧美日本韩国一区| 亚洲日本欧美天堂| 国产乱码精品一区二区三| 欧美人与禽zozo性伦| 日韩伦理电影网| 国产成人精品影院| 欧美mv日韩mv亚洲| 婷婷中文字幕一区三区| 91美女蜜桃在线| 日本一区二区久久| 国产专区综合网| 日韩精品一区二区三区四区视频 | 欧美精品色综合| 夜夜嗨av一区二区三区中文字幕| 成人午夜激情片| 欧美精彩视频一区二区三区| 极品少妇xxxx精品少妇偷拍| 91精品久久久久久久99蜜桃 | 国产精品久久久久久久久免费桃花| 久久丁香综合五月国产三级网站| 欧美三级电影精品| 亚洲电影中文字幕在线观看| 色婷婷国产精品| 伊人性伊人情综合网| 91成人免费网站| 亚洲福利视频三区| 欧美精选一区二区| 日本午夜精品视频在线观看| 欧美精品xxxxbbbb|