Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- #include <thread>
- /*
- *******
- *#####*
- *#***#*
- *#***#*
- *#***#*
- *#####*
- *******
- */
- int main()
- {
- const char* CSI = "\033[";
- const char* CLRSCR = "2J";
- int side{15};
- int sub{ 1 };
- //std::cout << "enter line length\n";
- //std::cin >> side;
- const char pos = '#';
- const char neg = ' ';
- bool positive{ false };
- bool hPositive{ false };
- bool vPositive{ false };
- const int maxLoop{ 6 };
- const int minLoop{ 0 };
- int loop{ minLoop };
- int loopStep{ 1 };
- while (true)
- {
- if ((loop >= maxLoop and loopStep > 0) or (loop <= minLoop and loopStep < 0))
- {
- loopStep *= -1;
- std::cout << '\n';
- }
- sub = loop;
- for (int y{ 0 }; y < side; ++y)
- {
- for (int x{ 0 }; x < side; ++x)
- {
- hPositive = ((y == sub or y == (side - 1 - sub)) and (x >= sub and x <= (side - 1 - sub)));
- vPositive = ((x == sub or x == (side - 1 - sub)) and (y >= sub and y <= (side - 1 - sub)));
- positive = (hPositive or vPositive);
- std::cout << ' ' << (positive ? pos : neg) << ' ';
- }
- std::cout << '\n';
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(1000)); //make some pause for better output look :)
- std::cout << CSI << CLRSCR; //portable clear screen
- loop += loopStep;
- }
- return 0;
- }
- //std::this_thread::sleep_for(std::chrono::milliseconds(200)); //make some pause for better output look :)
- //const char* CSI = "\033[";
- //std::cout << CSI << "2J"; //portable clear screen
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement