Advertisement
Bertran_rz

Untitled

Jul 23rd, 2021
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.82 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     const int height = 5, width = 5;
  8.     int menu_choise;        
  9.  
  10.     do
  11.     {
  12.         cout << "\nMENU:\n";
  13.         cout << "[1.  right - top triangle]\n";
  14.         cout << "[2.  Left - down triangle]\n";
  15.         cout << "[3.  top triangle]\n";
  16.         cout << "[4.  down triangle]\n";
  17.         cout << "[5.  top - down triangle]\n";
  18.         cout << "[6.  left - right triangle]\n";
  19.         cout << "[7.  left triangle]\n";
  20.         cout << "[8.  right triangle]\n";
  21.         cout << "[9.  left - top triangle]\n";
  22.         cout << "[10. down - right triangle]\n";
  23.         cin >> menu_choise;
  24.        
  25.         switch(menu_choise)
  26.         {
  27.             case 1:
  28.             {
  29.                 for(int i = 0; i < height; i++)
  30.                 {
  31.                     for(int j = 0; j < width; j++)
  32.                     {
  33.                         if(i < j || i == j) cout <<  "*";
  34.                         else cout << " ";
  35.                     }
  36.                     cout << "\n";
  37.                 }
  38.             }break;
  39.             case 2:
  40.             {
  41.                 for(int i = 0; i < height; i++)
  42.                 {
  43.                     for(int j = 0; j < width; j++)
  44.                     {  
  45.                         if(i > j || i == j) cout << "*";
  46.                         else cout << " ";
  47.                     }
  48.                     cout << "\n";
  49.                 }
  50.             }break;
  51.             case 3:
  52.             {
  53.                 for(int i = 0; i < height; i++)
  54.                 {
  55.                     for(int j = 0; j < width; j++)
  56.                     {
  57.                         if((i < j || i == j) && (i + j) <= 4) cout << "*";
  58.                         else cout << " ";
  59.                     }
  60.                     cout << "\n";
  61.                 }
  62.             }break;
  63.             case 4:
  64.             {
  65.                 for(int i = 0; i < height; i++)
  66.                 {
  67.                     for(int j = 0; j < width; j++)
  68.                     {
  69.                         if((i > j || i == j) && (i + j) >= 4) cout << "*";
  70.                         else cout << " ";
  71.                     }
  72.                     cout << "\n";
  73.                 }
  74.             }break;
  75.             case 5:
  76.             {
  77.                 for(int i = 0; i < height; i++)
  78.                 {
  79.                     for(int j = 0; j < width; j++)
  80.                     {
  81.                         if( ((i > j) && ((i + j) >= height-1)) || ((i < j) && ((i+j) <= width-1)) || i == j) cout << "*";
  82.                         else cout << " ";
  83.                     }
  84.                     cout << "\n";
  85.                 }
  86.             }break;
  87.             case 6:
  88.             {
  89.                 for(int i = 0; i < height; i++)
  90.                 {
  91.                     for(int j = 0; j < width; j++)
  92.                     {
  93.                         if( ((i > j) && ((i + j) <= height-1)) || ((i < j) && ((i+j) >= width-1)) || i == j) cout << "*";
  94.                         else cout << " ";
  95.                     }
  96.                     cout << "\n";
  97.                 }
  98.             }break;
  99.             case 7:
  100.             {
  101.                 for(int i = 0; i < height; i++)
  102.                 {
  103.                     for(int j = 0; j < width; j++)
  104.                     {
  105.                         if((i>j) && ((i+j) <= height-1) || (i == j && (i+j) < width)) cout << "*";
  106.                         else cout << " ";
  107.                     }
  108.                     cout << "\n";
  109.                 }
  110.             }break;
  111.             case 8:
  112.             {
  113.                 for(int i = 0; i < height; i++)
  114.                 {
  115.                     for(int j = 0; j < width; j++)
  116.                     {
  117.                         if((i<j) && ((i+j) >= height-1) || ((i == j) && (i+j) >= width-1))  cout << "*";
  118.                         else cout << " ";
  119.                     }
  120.                     cout << "\n";
  121.                 }
  122.             }break;
  123.             case 9:
  124.             {
  125.                 for(int i = 0; i < height; i++)
  126.                 {  
  127.                     for(int j = 0; j < width; j++)
  128.                     {
  129.                         if((i+j)<height) cout << "*";
  130.                         else cout << " ";
  131.                     }
  132.                     cout << "\n";
  133.                 }
  134.             }break;
  135.             case 10:
  136.             {
  137.                 for(int i = 0; i < height; i++)
  138.                 {
  139.                     for(int j = 0; j < width; j++)
  140.                     {
  141.                         if((i+j)>=width-1) cout << "*";
  142.                         else cout << " ";
  143.                     }
  144.                     cout << "\n";
  145.                 }
  146.             }break;
  147.             case 0:break;
  148.             default:
  149.                 cout  << "Bad choise, try again\n";
  150.             break;
  151.         }
  152.     }
  153.     while(menu_choise);
  154. }  
  155.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement