Advertisement
HyperSensualNarwhal

Moving arrow

Dec 19th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <conio.h>
  4.  
  5. using std::cout;
  6. using std::cin;
  7. using std::endl;
  8.  
  9. void main()
  10. {
  11.     int pos = 0, size = (setlocale(LC_ALL, "Russian"), cout << "Введите размер фигуры: ", cin >> size, size /= 2, size);
  12.     char move = 0;
  13.  
  14.     while (true)
  15.     {
  16.         for (int i = 0; i < size; i++, cout << endl)
  17.         for (int j = 0; j < size * 10; ((j == 0 + pos || j == i + 2 + pos) ? cout << ' ' : cout << '*'), j++);
  18.  
  19.         for (int i = 0; i < size; i++, cout << endl)
  20.         for (int j = 0; j < size * 10; ((j == 0 + pos || j == size - i + 1 + pos) ? cout << ' ' : cout << '*'), j++);
  21.  
  22.         move = getch();
  23.  
  24.         if (move == 100 || move == 68)
  25.         {
  26.             if (pos < size * 10) pos++;
  27.             else pos = 0;
  28.         }
  29.    
  30.  
  31.        
  32.  
  33.         Sleep(50);
  34.         system("cls");
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement