Advertisement
HyperSensualNarwhal

Chessboard through ternary operator

Dec 2nd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 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.     int a;
  11.     char ch = 223;
  12.  
  13.     //cout << "Enter size of chessboard: "; cin >> a;
  14.     cout << "Введите размер доски: "; cin >> a;
  15.     setlocale(LC_ALL, "C");
  16.     for (int i = 0; i < a; i++, cout << endl) for (int j = 1; j < a + 1; j++) (((i + j) % 2) == 1) ? cout << ch << " " : cout << "  ";
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement