Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- const int size{ 9 };
- int a, b, c, d;
- char input{ 'x' };
- bool positive{ false };
- const char pos{ '*' };
- const char neg{ ' ' };
- int main()
- {
- do
- {
- std::cout << "Enter figure a, b, c, d, e, f, g, h, i, j or x to exit\n";
- std::cin >> input;
- if (input == 'a') { a = -1; b = 1; c = 1; d = 1; }
- else if (input == 'b') { a = -1; b = -1; c = 1; d = -1; }
- else if (input == 'c') { a = -1; b = 1; c = -1; d = 1; }
- else if (input == 'd') { a = 1; b = -1; c = 1; d = -1; }
- else if (input == 'e') { a = -1; b = 1; c = 1; d = -1; }
- else if (input == 'f') { a = -1; b = -1; c = 1; d = 1; }
- else if (input == 'g') { a = -1; b = -1; c = -1; d = -1; }
- else if (input == 'h') { a = 1; b = 1; c = 1; d = 1; }
- else if (input == 'i') { a = -1; b = -1; c = -1; d = 1; }
- else if (input == 'j') { a = 1; b = -1; c = 1; d = 1; }
- else if (input == 'x') { break; }
- else { std::cout << "Incorrect input\n"; continue; };
- for (int y{ 0 }; y < size; ++y)
- {
- for (int x{ 0 }; x < size; ++x)
- {
- positive = (a * (x + y) >= a * (size - 1) and b * x >= b * y) or (c * (x + y) >= c * (size - 1) and d * x >= d * y);
- std::cout << ' ' << (positive ? pos : neg) << ' ';
- }
- std::cout << '\n';
- }
- std::cout << '\n';
- } while (input != 'x');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement