Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- // size = 6
- // 0 1 2 3 4 5
- //0 * # # # # *
- //1 # * # # * #
- //2 # # * * # #
- //3 # # * * # #
- //4 # * # # * #
- //5 * # # # # *
- // a > b -> a < b
- // -4 -3 -2 -1 0 1 2 3 4
- // b < a a < b
- int main()
- {
- int size{ 9 };
- std::cout << "Enter size\n";
- std::cin >> size;
- bool positive{ true };
- const char pos{ '*' };
- const char neg{ ' ' };
- for (int y{ 0 }; y < size; ++y)
- {
- for (int x{ 0 }; x < size; ++x)
- {
- //positive = ((x + y == size - 1) or (x == y));
- positive = ((x + y <= size - 1 ) and ( x >= y));
- std::cout << ' ' << (positive ? pos : neg) << ' ';
- }
- std::cout << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement