Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // triangles.cpp
- #include <iostream>
- using namespace std;
- int main()
- {
- int star;
- int chose;
- do
- {
- cout << "Please enter the size of the triangles" << endl;
- cin >> star;
- cout << "Please enter what the triangle should look like (1 to 10 )" << endl;
- cin >> chose;
- switch (chose)
- {
- case 1:
- // !a)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i <= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 2:
- // !b)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i >= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 3:
- // !c)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j < 9 && i <= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 4:
- // !d)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j > star - 1 && i >= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 5:
- // !e)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j < star - 1 && i <= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j > star - 1 && i >= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 6:
- // !f)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j < star - 1 && i >= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j > star - 1 && i <= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 7:
- // !g)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j < star - 1 && i >= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 8:
- // !h)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j > star - 1 && i <= j)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 9:
- // !i)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j > star)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- case 10:
- // !j)
- for (int i = 0; i < star; i++)
- {
- for (int j = 0; j < star; j++)
- {
- if (i + j < star)
- {
- cout << "*";
- }
- else
- {
- cout << " ";
- }
- }
- cout << endl;
- }
- break;
- default:
- break;
- }
- } while (chose >= 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement