Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- #define Q "$"
- #define Fil "."
- struct cell {
- int x, y;
- int imp;
- cell() { x = -1; y = -1; imp = 0;}
- };
- cell toDraw[8];
- bool draw_now(int x, int y)
- {
- for (int i = 0; i < 7; i++)
- if (toDraw[i].x == x && toDraw[i].y == y) return true;
- return false;
- }
- void draw_board()
- {
- int funcX = 0, funcY = 0;
- // Top board edge
- cout << "\n\t";
- cout << (char)218;
- for (int i = 0; i < 7; i++)
- cout << (char)196 << (char)194;
- cout << (char)196 << (char)191;
- cout << "\n\t";
- for (int i = 0; i < 7; i++) {
- // Base of every string
- cout << (char)179;
- for (int i = 0; i < 7; i++) {
- if (draw_now(funcX, funcY)) cout << Q;
- else cout << Fil;
- cout << (char)179;
- funcX++;
- }
- if (draw_now(funcX, funcY)) cout << Q;
- else cout << Fil;
- cout << (char)179;
- funcX = 0;
- cout << "\n\t";
- cout << (char)195;
- for (int i = 0; i < 7; i++)
- cout << (char)196 << (char)197;
- cout << (char)196 << (char)180;
- cout << "\n\t";
- funcY++;
- }
- // Last string
- cout << (char)179;
- for (int i = 0; i < 7; i++) {
- if (draw_now(funcX, funcY)) cout << Q;
- else cout << Fil;
- cout << (char)179;
- funcX++;
- }
- if (draw_now(funcX, funcY)) cout << Q;
- else cout << Fil;
- cout << (char)179;
- cout << "\n\t";
- // Bottom board edge
- cout << (char)192;
- for (int i = 0; i < 7; i++)
- cout << (char)196 << (char)193;
- cout << (char)196 << (char)217;
- cout << "\n";
- }
- int main()
- {
- cell board[8][8];
- for (int i = 0; i < 8; i++)
- for (int j = 0; j < 8; j++) {
- board[i][j].x = i;
- board[i][j].y = j;
- }
- toDraw[2].x = 3;
- toDraw[2].y = 4;
- toDraw[0].x = 1;
- toDraw[0].y = 2;
- cout << "\nChess board. " << Q << " - Queen: ";
- draw_board();
- cout << "\n";
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement