Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void topTriangle(int num1, int k);
- void bottomTriangle(int num1, int k);
- void main()
- {
- int num1, k;
- cout << "enter num1 and k" << endl;
- cin >> num1 >> k;
- topTriangle(num1, k);
- bottomTriangle(num1, k);
- }
- void topTriangle(int num1,int k)
- {
- int line, j;
- for (line = 1; line <= num1; line++)
- {
- for (j = 1; j < line; j++)
- {
- cout << " ";
- }
- for (j = line; j <= num1; j++)
- {
- cout << j;
- }
- for (j = num1 - 1; j >= line; j--)
- {
- cout << j;
- }
- cout << "\n";
- }
- }
- void bottomTriangle(int num1,int k)
- {
- int i, j, g;
- for (i = 1; i <= num1;i++)
- {
- for (j = 1; j <= (num1 - i - 1); j++)
- {
- cout << " ";
- }
- for (g = 1; g <= (2 * i + 1); g++)
- {
- cout << g;
- }
- cout << "\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment