Advertisement
avr39ripe

hwLineMenu

Oct 28th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <chrono>
  3. #include <thread>
  4.  
  5. int main()
  6. {
  7.     int length{0};
  8.     char symb{ '#' };
  9.     bool horizontal{true};
  10.     int delay{ 100 };
  11.  
  12.     char option{};
  13.     bool correct{true};
  14.  
  15.     //std::cout.setf(std::ios::unitbuf); // need for unbuffered output on some systems
  16.  
  17.     std::cout << "Enter line length\n";
  18.     std::cin >> length;
  19.  
  20.     std::cout << "Enter symbol to form the line\n";
  21.     std::cin >> symb;
  22.  
  23.     do
  24.     {
  25.         std::cout << "Enter line direction h - horizontal, v - vertical\n";
  26.         std::cin >> option;
  27.         correct = (option == 'h' or option == 'v');
  28.     }while( !correct );
  29.  
  30.     horizontal = (option == 'h');
  31.  
  32.     do
  33.     {
  34.         std::cout << "Enter drawing speed l - low, m - medium, h - high\n";
  35.         std::cin >> option;
  36.         correct = (option == 'l' or option == 'm' or option == 'h');
  37.     }while( !correct );
  38.  
  39.     if ( option == 'l' )
  40.     {
  41.         delay = 500;
  42.     }
  43.     else if ( option == 'm')
  44.     {
  45.         delay = 300;
  46.     }
  47.  
  48.  
  49.     for (; length; --length)
  50.     {
  51.         std::cout << symb;
  52.         if (!horizontal)
  53.         {
  54.             std::cout << '\n';
  55.         }
  56.         std::this_thread::sleep_for(std::chrono::milliseconds(delay));
  57.     }
  58.  
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement