<> effect

<> code
#include<iostream> #include <windows.h> using namespace std; class ChessBoard {
private: int **chessBoard; int size; int xd, yd; int triangle; public:
ChessBoard(int s, int x, int y) { size = s; chessBoard = new int*[size]; for (
int i = 0; i < size; i++) { chessBoard[i] = new int[size]; for (int j = 0; j <
size; j++) chessBoard[i][j] = 0; } xd = x, yd = y; chessBoard[xd][yd] = -1;
triangle= 0; } int search(int lx, int ly, int rx, int ry, int len); void cover(
int lx, int ly, int rx, int ry, int len, int tri); void display(); }; int
ChessBoard::search(int lx, int ly, int rx, int ry, int len) { int i, j; bool
flag= false; for (i = lx; i <= rx; i++) { for (j = ly; j <= ry; j++) { if (
chessBoard[i][j] != 0) { flag = true; break; } } if (flag) break; } int ox = lx
+ len; int oy = ly + len; if (i >= ox && j >= oy) return 4; // Delta Quadrant if (i < ox &&
j>= oy) return 1; // first quadrant if (i >= ox && j < oy) return 3; // third quadrant if (i < ox &&
j< oy) return 2; // Beta Quadrant } void ChessBoard::cover(int lx, int ly, int rx, int ry,
int len, int color) { if (len == 0) return; // No empty block triangle++; if (len >= 2)
color= 1; int quadrant = search(lx, ly, rx, ry, len); if (quadrant == 1) {
chessBoard[lx + len][ly + len] = color; //4 chessBoard[lx + len][ly + len - 1] =
color; //3 chessBoard[lx + len - 1][ly + len - 1] = color; //2 } else if (
quadrant== 2) { chessBoard[lx + len - 1][ly + len] = color; //1 chessBoard[lx +
len][ly + len] = color; //4 chessBoard[lx + len][ly + len - 1] = color; //3 }
else if (quadrant == 3) { chessBoard[lx + len - 1][ly + len] = color; //1
chessBoard[lx + len - 1][ly + len - 1] = color; //2 chessBoard[lx + len][ly +
len] = color; //4 } else if (quadrant == 4) { chessBoard[lx + len - 1][ly + len]
= color; //1 chessBoard[lx + len - 1][ly + len - 1] = color; //2 chessBoard[lx +
len][ly + len - 1] = color; //3 } // Divide and conquer cover(lx, ly + len, lx + len - 1, ry,
len/ 2, 2); //1 cover(lx, ly, lx + len - 1, ly + len - 1, len / 2, 3); //2 cover
(lx + len, ly, rx, ly + len - 1, len / 2, 2); //3 cover(lx + len, ly + len, rx,
ry, len / 2, 3); //4 } void ChessBoard::display() { // Color code : 0= black 1 blue 2 green 3 Lake blue
4 gules 5 violet 6 yellow 7 white 8 grey 9 Light blue enum colour { black, blue, green, lake_blue, red,
purple, yellow, white, grey, baby_blue }; int forecolour = white, backcolour;
HANDLE handle; // Get handle handle = GetStdHandle(STD_OUTPUT_HANDLE); // Get handle to small black box
COORD coord; // Get axis structure for (int i = 0; i < size; i++) { for (int j = 0; j <
size; j++) { coord.X = i; coord.Y = j + 2; SetConsoleCursorPosition(handle,
coord); // Move cursor to x,y place if (chessBoard[i][j] == -1) backcolour = white; else if (
chessBoard[i][j] == 1) backcolour = yellow; else if (chessBoard[i][j] == 2)
backcolour= lake_blue; else if (chessBoard[i][j] == 3) backcolour = red;
SetConsoleTextAttribute(handle, forecolour + backcolour * 0x10);// Change the background and font color of the current cursor
cout<< " "; } cout << endl; } backcolour = black; SetConsoleTextAttribute(
handle, forecolour + backcolour * 0x10);// Change the background and font color of the current cursor cout << " Number of common three partitions : " <<
triangle<< endl; } int main(void) { int k, x, y; cout << " input k: "; cin >> k; cout
<< " Enter incomplete position (x,y): "; cin >> x >> y; int size = pow(2, k); ChessBoard chessBoard(
size, x, y); chessBoard.cover(0, 0, size - 1, size - 1, size / 2, 1); chessBoard
.display(); system("pause"); return 0; }

Technology
©2019-2020 Toolsou All rights reserved,
TP6 Application examples of verifier and correct verification data ESP8266/ESP32 System : Optimize system startup time 2021 year 2 Chinese programming language ranking 2021 year 1 Monthly programmer salary statistics , average 14915 element CSS architecture design It's not depravity that's terrible , It's about knowing you're falling Gude Haowen serial - You deserve to be an engineer ( Preface ) Software testing BUG describe C Course design of language programming of 《 Student achievement management system 》vue In the project axios Global encapsulation of