avr39ripe

chessTable

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