Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;
Namespace chessboard
{
Class Program
{
Public static int [,] Board = new int [8, 8];
Public static int tail = 0;
Static void main (string [] ARGs)
{
Chessboard (0, 0, 4, 7, 8 );
For (INT I = 0; I <8; I ++)
{
For (Int J = 0; j <8; j ++)
{
Console. Write ("{0, 5}", Board [I, j]);
}
Console. Write ("\ n ");
}
Console. Read ();
}
Public static void chessBoard (int tr, int tc, int dr, int dc, int size)
{
If (size = 1) return;
Int s = size/2;
Int t = tail ++;
// The Special square is in the upper left corner.
If (Dr <tr + S & DC <TC + S)
{
Chessboard (TR, TC, Dr, DC, S );
}
Else
{
// The Special square is not in the upper left corner.
Board [tr + s-1, tc + s-1] = t;
ChessBoard (tr, tc, tr + s-1, tc + s-1, s );
}
// The Special square is in the upper right corner.
If (dr <tr + s & dc> = tc + s)
{
Chessboard (TR, TC + S, Dr, DC, S );
}
Else
{
// The Special square is not in the upper right corner.
Board [tr + s-1, TC + S] = T;
Chessboard (TR, TC + S, tr + s-1, TC + S, S );
}
// The Special square is in the lower left corner.
If (dr> = tr + s & dc <tc + s)
{
ChessBoard (tr + s, tc, dr, dc, s );
}
Else
{
// The Special square is not in the lower left corner.
Board [tr + s, tc + s-1] = t;
ChessBoard (tr + s, tc, tr + s, tc + s-1, s );
}
// The Special square is in the lower right corner.
If (dr> = tr + s & dc> = tc + s)
{
ChessBoard (tr + s, tc + s, dr, dc, s );
}
Else
{
// The Special square is not in the lower right corner.
Board [tr + s, tc + s] = t;
ChessBoard (tr + s, tc + s, tr + s, tc + s, s );
}
}
}
}