Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <chrono>
- #include <thread>
- /*
- * side = 5
- *
- *
- 0 1 2 3 4
- 0 # # # # #
- 1 # # # # #
- 2 # # # # #
- 3 # # # # #
- 4 # # # # #
- 0 1 2 3 4
- 0 * * * * *
- 1 # * * * *
- 2 # # * * *
- 3 # # # * *
- 4 # # # # *
- */
- // -4 -3 -2 -1 0 1 2 3 4
- // b > a a < b
- // a < b
- // a > b
- // a >= b
- // -a <= -b
- int main()
- {
- int side{5};
- //std::cout << "enter line length\n";
- //std::cin >> side;
- char symb = '#';
- for (int y{ 0 }; y < side; ++y)
- {
- for (int x{ 0 }; x < side; ++x)
- {
- symb = '*';
- //if ((x + y == (side - 1)) or (x == y))
- if (x + y >= (side - 1) or (x <= y))
- {
- symb = ' ';
- }
- std::cout << ' ' << symb << ' ';
- }
- std::cout << '\n';
- }
- return 0;
- }
- //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