Advertisement
avr39ripe

cppChessBoardAlt

Jul 11th, 2021 (edited)
871
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5.     const int boardSize{ 8 };
  6.     const int widthScale{ 2 };
  7.     const char black{ ' ' };
  8.     const char white{ '#' };
  9.  
  10.     bool cellColor{ false };
  11.     int cellSize{};
  12.  
  13.     std::cout << "Enter cell size.\n";
  14.     std::cin >> cellSize;
  15.  
  16.     for (int boardHeight{ 0 }; boardHeight < boardSize; ++boardHeight)
  17.     {
  18.         for (int cellHeight{ 0 }; cellHeight < cellSize; ++cellHeight)
  19.         {
  20.             for (int boardWidth{ 0 }; boardWidth < boardSize; ++boardWidth)
  21.             {
  22.                 cellColor = boardWidth % 2 != boardHeight % 2;
  23.                 for (int cellWidth{ 0 }, maxCellWidth{ cellSize * widthScale }; cellWidth < maxCellWidth; ++cellWidth)
  24.                 {
  25.                     std::cout << (cellColor ? black : white);
  26.                 }
  27.             }
  28.             std::cout << '\n';
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement