Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- #include <thread>
- int main()
- {
- int length{0};
- char symb{ '#' };
- bool horizontal{true};
- int delay{ 100 };
- char option{};
- bool correct{true};
- //std::cout.setf(std::ios::unitbuf); // need for unbuffered output on some systems
- std::cout << "Enter line length\n";
- std::cin >> length;
- std::cout << "Enter symbol to form the line\n";
- std::cin >> symb;
- do
- {
- std::cout << "Enter line direction h - horizontal, v - vertical\n";
- std::cin >> option;
- correct = (option == 'h' or option == 'v');
- }while( !correct );
- horizontal = (option == 'h');
- do
- {
- std::cout << "Enter drawing speed l - low, m - medium, h - high\n";
- std::cin >> option;
- correct = (option == 'l' or option == 'm' or option == 'h');
- }while( !correct );
- if ( option == 'l' )
- {
- delay = 500;
- }
- else if ( option == 'm')
- {
- delay = 300;
- }
- for (; length; --length)
- {
- std::cout << symb;
- if (!horizontal)
- {
- std::cout << '\n';
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(delay));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement