Advertisement
avr39ripe

cppTriangleSquareMadness

May 27th, 2021
1,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.57 KB | None | 0 0
  1.     const int size{ 9 };
  2.     int a, b, c, d;
  3.     char input{ 'x' };
  4.     bool positive{ false };
  5.     do
  6.     {
  7.         std::cout << "Enter figure a, b, c, d, e, f, g, h, i, j or x to exit\n";
  8.         std::cin >> input;
  9.         if (input == 'a') { a = -1; b = 1; c = 1; d = 1; }
  10.         else if (input == 'b') { a = -1; b = -1; c = 1; d = -1; }
  11.         else if (input == 'c') { a = -1; b = 1; c = -1; d = 1; }
  12.         else if (input == 'd') { a = 1; b = -1; c = 1; d = -1; }
  13.         else if (input == 'e') { a = -1; b = 1; c = 1; d = -1; }
  14.         else if (input == 'f') { a = -1; b = -1; c = 1; d = 1; }
  15.         else if (input == 'g') { a = -1; b = -1; c = -1; d = -1; }
  16.         else if (input == 'h') { a = 1; b = 1; c = 1; d = 1; }
  17.         else if (input == 'i') { a = -1; b = -1; c = -1; d = 1; }
  18.         else if (input == 'j') { a = 1; b = -1; c = 1; d = 1; }
  19.         else if (input == 'x') { break; }
  20.         else { std::cout << "Incorrect input\n"; continue; };
  21.         for (int y = 0; y < size; ++y)
  22.         {
  23.             for (int x = 0; x < size; ++x)
  24.             {
  25.                            
  26.                 //positive = (a * (x + y) >= a * (size - 1) and b * x >= b * y) or (c * (x + y) >= c * (size - 1) and d * x >= d * y);
  27.                
  28.                 positive = ((a * y >= a * (size / 2)) and (b * x >= b * (size / 2))) or ((c * y >= c * (size / 2)) and (d * x >= d * (size / 2)));
  29.  
  30.                 std::cout << ' ' << (positive ? '*' : ' ') << ' ';
  31.  
  32.             }
  33.             std::cout << '\n';
  34.         }
  35.         std::cout << '\n';
  36.     } while (input != 'x');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement