Advertisement
NickAndNick

Квадраты

Oct 30th, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <conio.h>
  4. using namespace std;
  5. int main() {
  6.     const size_t size = 12;
  7.     char square[size], symbol;
  8.     for (size_t i = 0; i < size; ++i) {
  9.         if (0 == (i + 1) % 4) square[i] = '\n';
  10.         else {
  11.             symbol = _getch();
  12.             square[i] = symbol;
  13.         }
  14.         cout << square[i];
  15.     }
  16.     COORD coord;
  17.     coord.X = 8;
  18.     coord.Y = 0;
  19.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  20.     _getch();
  21.     for (size_t i = 0; i < size; ++i) {
  22.         if (0 == (i + 1) % 4){
  23.             coord.X = 8;
  24.             ++coord.Y;
  25.             SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  26.         }
  27.         else cout << square[i];
  28.     }
  29.     coord.X = 0;
  30.     coord.Y = 8;
  31.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  32.     _getch();
  33.     for (size_t i = 0; i < size; ++i) cout << square[i];
  34.     cin.sync();
  35.     cin.get();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement