Advertisement
avr39-ripe

chessTableAdvanced

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