Problem Description:
In a checkerboard of 2^k*2^k squares, there is a grid that differs from other squares, called special squares.
Now invite 4 different L-shaped dominoes to cover all squares of a given chessboard except for special parties.
For example: This is a k=2 when the board, the special point coordinates (0,1).
Four L-type dominoes
Program code:
#include <stdio. H> #define KEY 8//order of the chessboard int ar[key][key]={0}; A two-dimensional array saves the board, the initial value is full 0int tile=1; flag void Chessboard (int tr,int tc,int dr,int dc,int size) {int s=size/2; Split Checkerboard int flag;if (size==1) return; flag=++tile;//If the special point is in the upper left corner if (dr<tr+s && dc<tc+s) chessboard (TR,TC,DR, Dc,s); In the words, recursive else {ar[tr+s-1][tc+s-1]=flag; If not, assign the lower right corner of the chessboard in the upper-left corner as a sign ... Below are three similar chessboard (tr,tc,tr+s-1,tc+s-1,s); }//If the special point is in the upper right corner if (dr<tr+s && dc>=tc+s) chessboard (tr,tc+s,dr,dc,s); else {ar[tr+s-1][tc+s]=flag; chessboard (tr,tc+s,tr+s-1,tc+s,s);} If the special point is in the lower left corner if (dr>=tr+s && dc<tc+s) chessboard (tr+s,tc,dr,dc,s); else {ar[tr+s][tc+s-1]=flag; chessboard (tr+s,tc,tr+s,tc+s-1,s);} If the special point is in the lower right corner if (dr>=tr+s && dc>=tc+s) chessboard (tr+s,tc+s,dr,dc,s); else {ar[tr+s][tc+s]=flag; chessboard (tr+s,tc+s,tr+s,tc+s,s);}} void init (int x,int y)//Initializes a point for the special point {ar[x][y]=1;} int main () {int i,j;i=4;j=5;init (I,J); chessboard (0,0,i,j,8); for (i=0;i<8;i++) {for (j=0; j<8;j++) printf ("%2d", Ar[i][j]);p UTS ("");}}
Executes the result.
"Recursive" checkerboard Overlay