Advertisement
avr39ripe

chessBoard

Jul 15th, 2021
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     const int boardSize{ 8 };
  6.     bool cellColor{ true }; // true - black, false - white
  7.     int cellSize{ 2 };
  8.  
  9.     std::cout << "Enter cell size\n";
  10.     std::cin >> cellSize;
  11.     std::cout << '\n';
  12.     for (int y{ 0 }, boardMax{ boardSize * cellSize }; y < boardMax; ++y)
  13.     {
  14.         for (int x{ 0 }; x < boardMax; ++x)
  15.         {
  16.             cellColor = (x / cellSize + y / cellSize) % 2;
  17.             std::cout << (cellColor ? "  " : "##");
  18.         }
  19.         std::cout << '\n';
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement