Package algorithm; // recursive grouping solves the Board coverage problem. Public class chessboard {// tr the row number in the upper left corner of the board. // column number in the upper left corner of the TC board. // size = 2 ^ K the board type is 2 ^ K * 2 ^ K // row number of the Dr special square // column number of the DC special square Private Static int tile = 0; // L-type bone number public static int [] [] Board = new int [100] [100]; public static void chessboard (int tr, int TC, int DR, int DC, int size) {If (size = 1) return; size/= 2; int T = ++ tile; // If (Dr <tr + size & DC <TC + size) {chessboard (TR, TC, Dr, DC, size );} else {board [tr + size-1] [TC + size-1] = T; chessboard (TR, TC, tr + size-1, TC + size-1, size) ;}// if (Dr <tr + size & DC> = TC + size) {chessboard (TR, TC + size, Dr, DC, size);} else {board [tr + size-1] [TC + size] = T; chessboard (TR, TC + size, tr + size-1, TC + size, size) ;}// if (Dr> = tr + size & DC <TC + size) {chessboard (tr + size, TC, Dr, DC, size);} else {board [tr + size] [TC + size-1] = T; chessboard (tr + size, TC, tr + size, TC + size-1, size) ;}// if (Dr> = tr + size & DC> = TC + size) {chessboard (tr + size, TC + size, Dr, DC, size) ;}else {board [tr + size] [TC + size] = T; chessboard (tr + size, TC + size, tr + size, TC + size, size) ;}} public static void main (string [] ARGs) {// todo auto-generated method stubint size = 8; chessboard (0, 0, 3, 3, size ); for (INT I = 0; I <size; I ++) {for (Int J = 0; j <size; j ++) {string S = string. format ("% 3d", Board [I] [J]); system. out. print (s);} system. out. println ();}}}
Recursive Sub-governance solves the Board coverage Problem