Basic Inverse Pyramid Program!
Can anyone please explain how i would manipulate the following program to reflect an inverse pyramid and how to also get an upside down pyramid?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int i, j, k, n;
cout<<("Enter number of rows for pyramid: ");
cin>> n;
cout<<("\n");
for (i = 1; i <= n; i++)
{
for (j = 0; j < (n - i); j++)
cout<<(" ");
for (j = 1; j <= i; j++)
cout<<("*");
for (k = 1; k < i; k++)
cout<<("*");
cout<<("\n");
}
cout<<("\n\n");
system("PAUSE");
return 0;
}
|
Topic archived. No new replies allowed.