Advertisement
HyperSensualNarwhal

Chessboard by symbols '+' and '-'

Nov 28th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using std::cout;
  4. using std::cin;
  5. using std::endl;
  6.  
  7. void main()
  8. {
  9.     setlocale(LC_ALL, "Russian");
  10.  
  11.     int a, temp;
  12.  
  13.     cout << "Введите размер шахматной доски: "; cin >> a;
  14.  
  15.     for (int i = 0; i < a; i++)
  16.     {
  17.             for (int j = 1; j < a + 1; j++)
  18.             {
  19.  
  20.                 temp = (i + j) % 2;
  21.  
  22.                 if (temp == 1)  cout << '+' << " ";
  23.                 else            cout << '-' << " ";
  24.             }
  25.        
  26.         cout << endl;
  27.  
  28.     }
  29.    
  30.     cout << endl;
  31.    
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement