Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- const int maxCord{ 5 };
- int a, b, c, d;
- char input{ 'x' };
- bool flag{ true };
- 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 < maxCord; ++y)
- {
- for (int x = 0; x < maxCord; ++x)
- {
- flag = ((a * (x + y) >= a * (maxCord - 1) and b * x >= b * y) or (c * (x + y) >= c * (maxCord - 1) and d * x >= d * y));
- //flag = ((x + y) == (maxCord - 1) or (x == y));
- //flag = (a * (x + y) >= a * (maxCord - 1) and b * x >= b * y);
- std::cout << ' ' << ( flag ? '*' : ' ') << ' ';
- //std::cout << (flag ? '*' : ' ');
- }
- std::cout << '\n';
- }
- std::cout << '\n';
- } while (input != 'x');
- }
- // a >= b
- // (-1) * a >= (-1) * b
- //
- //flag = (((x + y) == (maxCord - 1) and x == y)
- //or ((x + y) == (maxCord - 1) and x == y))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement