Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- #include <thread>
- int main()
- {
- const int maxLoop{ 10 };
- const int minLoop{ 0 };
- int loop{ maxLoop };
- int loopStep{1};
- while (true)
- {
- if ((loop >= maxLoop and loopStep > 0) or (loop <= minLoop and loopStep < 0))
- {
- loopStep *= -1;
- std::cout << '\n';
- }
- if (loop >= minLoop and loop <= maxLoop)
- {
- std::cout << loop << ' ';
- }
- loop += loopStep;
- std::this_thread::sleep_for(std::chrono::milliseconds(200)); //make some pause for better output look :)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement