Advertisement
avr39-ripe

triangleMadness

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