Advertisement
GarikK

triangles

Mar 2nd, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.38 KB | None | 0 0
  1. // triangles.cpp
  2.  
  3. #include <iostream>
  4. using namespace std;
  5. int main()
  6. {
  7.     int star;
  8.     int chose;
  9.     do
  10.     {
  11.         cout << "Please enter the size of the triangles" << endl;
  12.         cin >> star;
  13.         cout << "Please enter what the triangle should look like (1 to 10 )" << endl;
  14.         cin >> chose;
  15.         switch (chose)
  16.         {
  17.         case 1:
  18.             // !a)
  19.             for (int i = 0; i < star; i++)
  20.             {
  21.                 for (int j = 0; j < star; j++)
  22.                 {
  23.                     if (i <= j)
  24.                     {
  25.                         cout << "*";
  26.                     }
  27.                     else
  28.                     {
  29.                         cout << " ";
  30.                     }
  31.                 }
  32.                 cout << endl;
  33.             }
  34.             break;
  35.         case 2:
  36.             // !b)
  37.             for (int i = 0; i < star; i++)
  38.             {
  39.                 for (int j = 0; j < star; j++)
  40.                 {
  41.                     if (i >= j)
  42.                     {
  43.                         cout << "*";
  44.                     }
  45.                     else
  46.                     {
  47.                         cout << " ";
  48.                     }
  49.                 }
  50.                 cout << endl;
  51.             }
  52.             break;
  53.         case 3:
  54.             // !c)
  55.             for (int i = 0; i < star; i++)
  56.             {
  57.                 for (int j = 0; j < star; j++)
  58.                 {
  59.                     if (i + j < 9 && i <= j)
  60.                     {
  61.                         cout << "*";
  62.                     }
  63.                     else
  64.                     {
  65.                         cout << " ";
  66.                     }
  67.                 }
  68.                 cout << endl;
  69.             }
  70.             break;
  71.         case 4:
  72.             // !d)
  73.             for (int i = 0; i < star; i++)
  74.             {
  75.                 for (int j = 0; j < star; j++)
  76.                 {
  77.                     if (i + j > star - 1 && i >= j)
  78.                     {
  79.                         cout << "*";
  80.                     }
  81.                     else
  82.                     {
  83.                         cout << " ";
  84.                     }
  85.                 }
  86.                 cout << endl;
  87.             }
  88.             break;
  89.         case 5:
  90.             // !e)
  91.             for (int i = 0; i < star; i++)
  92.             {
  93.                 for (int j = 0; j < star; j++)
  94.                 {
  95.                     if (i + j < star - 1 && i <= j)
  96.                     {
  97.                         cout << "*";
  98.                     }
  99.                     else
  100.                     {
  101.                         cout << " ";
  102.                     }
  103.                 }
  104.                 cout << endl;
  105.             }
  106.             for (int i = 0; i < star; i++)
  107.             {
  108.                 for (int j = 0; j < star; j++)
  109.                 {
  110.                     if (i + j > star - 1 && i >= j)
  111.                     {
  112.                         cout << "*";
  113.                     }
  114.                     else
  115.                     {
  116.                         cout << " ";
  117.                     }
  118.                 }
  119.                 cout << endl;
  120.             }
  121.             break;
  122.         case 6:
  123.             // !f)
  124.             for (int i = 0; i < star; i++)
  125.             {
  126.                 for (int j = 0; j < star; j++)
  127.                 {
  128.                     if (i + j < star - 1 && i >= j)
  129.                     {
  130.                         cout << "*";
  131.                     }
  132.                     else
  133.                     {
  134.                         cout << " ";
  135.                     }
  136.                 }
  137.                 cout << endl;
  138.             }
  139.             for (int i = 0; i < star; i++)
  140.             {
  141.                 for (int j = 0; j < star; j++)
  142.                 {
  143.                     if (i + j > star - 1 && i <= j)
  144.                     {
  145.                         cout << "*";
  146.                     }
  147.                     else
  148.                     {
  149.                         cout << " ";
  150.                     }
  151.                 }
  152.                 cout << endl;
  153.             }
  154.             break;
  155.         case 7:
  156.             // !g)
  157.             for (int i = 0; i < star; i++)
  158.             {
  159.                 for (int j = 0; j < star; j++)
  160.                 {
  161.                     if (i + j < star - 1 && i >= j)
  162.                     {
  163.                         cout << "*";
  164.                     }
  165.                     else
  166.                     {
  167.                         cout << " ";
  168.                     }
  169.                 }
  170.                 cout << endl;
  171.             }
  172.             break;
  173.         case 8:
  174.             // !h)
  175.             for (int i = 0; i < star; i++)
  176.             {
  177.                 for (int j = 0; j < star; j++)
  178.                 {
  179.                     if (i + j > star - 1 && i <= j)
  180.                     {
  181.                         cout << "*";
  182.                     }
  183.                     else
  184.                     {
  185.                         cout << " ";
  186.                     }
  187.                 }
  188.                 cout << endl;
  189.             }
  190.             break;
  191.         case 9:
  192.             // !i)
  193.             for (int i = 0; i < star; i++)
  194.             {
  195.                 for (int j = 0; j < star; j++)
  196.                 {
  197.                     if (i + j > star)
  198.                     {
  199.                         cout << "*";
  200.                     }
  201.                     else
  202.                     {
  203.                         cout << " ";
  204.                     }
  205.                 }
  206.                 cout << endl;
  207.             }
  208.             break;
  209.         case 10:
  210.             // !j)
  211.             for (int i = 0; i < star; i++)
  212.             {
  213.                 for (int j = 0; j < star; j++)
  214.                 {
  215.                     if (i + j < star)
  216.                     {
  217.                         cout << "*";
  218.                     }
  219.                     else
  220.                     {
  221.                         cout << " ";
  222.                     }
  223.                 }
  224.                 cout << endl;
  225.             }
  226.             break;
  227.         default:
  228.             break;
  229.         }
  230.     } while (chose >= 1);
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement