avr39-ripe

crossCord

Mar 9th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <chrono>
  4. #include <thread>
  5. char block = '#';
  6. const int maxCord = 10;
  7.  
  8. const int maxLoop = maxCord-1 ;
  9. const int minLoop = 0;
  10. int loopStep = 1;
  11. int loop = minLoop;
  12.  
  13.  
  14. using namespace std;
  15. int main()
  16. {
  17.     while (true)
  18.     {
  19.        
  20.         for (int y = 0; y < maxCord; y++)
  21.         {
  22.             for (int x = 0; x < maxCord; x++)
  23.             {
  24.                 block = ' ';
  25.                 if (x == loop) { block = '*'; };
  26.                 if (y == loop) { block = '*'; };
  27.                 cout << ' ' << block << ' ';
  28.             }
  29.             cout << endl;
  30.         }
  31.  
  32.         if ((loop == maxLoop && loopStep > 0) || (loop == minLoop && loopStep < 0)) { loopStep *= -1; };
  33.         loop += loopStep;
  34.  
  35.         cout << endl;
  36.         std::this_thread::sleep_for(std::chrono::milliseconds(500));
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment