avr39-ripe

triangles Madness

Jun 25th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.46 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. const int maxCord = 9;
  5. int a,b,c,d;
  6. char input='x';
  7.  
  8. using namespace std;
  9. char block=' ';
  10. int main ()
  11. {
  12.     do
  13.     {
  14.     cout<<"Enter figure a, b, c, d, e, f, g, h, i, j or x to exit\n";
  15.     cin>>input;
  16.     if (input == 'a') {a=-1; b=1; c=1; d=1;}
  17.     else if (input == 'b') {a=-1; b=-1; c=1; d=-1;}
  18.     else if (input == 'c') {a=-1; b=1; c=-1; d=1;}
  19.     else if (input == 'd') {a=1; b=-1; c=1; d=-1;}
  20.     else if (input == 'e') {a=-1; b=1; c=1; d=-1;}
  21.     else if (input == 'f') {a=-1; b=-1; c=1; d=1;}
  22.     else if (input == 'g') {a=-1; b=-1; c=-1; d=-1;}
  23.     else if (input == 'h') {a=1; b=1; c=1; d=1;}
  24.     else if (input == 'i') {a=-1; b=-1; c=-1; d=1;}
  25.     else if (input == 'j') {a=1; b=-1; c=1; d=1;}
  26.     else if (input == 'x') {break;}
  27.     else {cout<<"Incorrect input\n"; continue; };
  28.    
  29.     for (int y=0; y < maxCord; y++)
  30.     {
  31.         for (int x = 0; x < maxCord; x++)
  32.         {
  33.             block=' ';
  34.             //(((x+y) >= (maxCord-1) && x >= y) || ((x+y) >= (maxCord-1) && x >= y)) / Main idea of triangles;
  35.             //if ( (a*(x+y) >= a*(maxCord-1) && b*x >= b*y) || (c*(x+y) >= c*(maxCord-1) && d*x >= d*y)) //For triangles
  36.  
  37.             //( (y >= maxCord/2 ) &&  ( x  >= maxCord/2) || ( y >= maxCord/2) &&  (x >= maxCord/2) ) // Main idea of squares
  38.             if ( (a*y >= a*maxCord/2 ) &&  ( b*x  >= b*maxCord/2) || ( c*y >= c*maxCord/2) &&  (d*x >= d*maxCord/2) ) //For squares
  39.             {
  40.                 block='*';
  41.             }
  42.             cout<<' '<<block<<' ';
  43.         }
  44.     cout << endl;
  45.     }
  46.     cout << endl;
  47.     }
  48.     while (input!='x');
  49. }
Advertisement
Add Comment
Please, Sign In to add comment