avr39ripe

triangleMadnessByAVR

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