Attempting to write a program, and I did it fairly strange but I still feel as if I can make it work.

The user input represents the total number of lines in the pyramid. You must use nested loops to implement your program.

(Hint: Each line has three parts: No of leading spaces, descending integers, and ascending integers. Consider line 3 in the above example: there is one leading space, the descending integers are 3, 2, 1 and the ascending integers are 2, 3. Try to find formula to compute the no. of leading space, ascending integers, and descending integers with to total number of lines.

)

The user input represents the total number of lines in the pyramid. You must use nested loops to implement your program.

(Hint: Each line has three parts: No of leading spaces, descending integers, and ascending integers. Consider line 3 in the above example: there is one leading space, the descending integers are 3, 2, 1 and the ascending integers are 2, 3. Try to find formula to compute the no. of leading space, ascending integers, and descending integers with to total number of lines.

)

**Warning: Spoiler!**(Click to show)

#include

using namespace std;

int main()

{

int First, Second, Third, Initial, Final=15, Space=0;

cout <<" Please enter an Integer from 1 to 15" << endl;

cin >> Initial;

Final=Final-Initial;

Second=Initial;

for (Third=15;Third<=15 && Third>0; Third--)

{

cout << " "; //each value of final results in a space

}

for (Initial; Initial <=15 && Initial >0; Initial--)

{

cout << Initial << " ";

}

for (Initial=2; Initial <= Second && Initial >0; Initial++)

{

cout << Initial << " ";

}

}

Trying to figure out how I can do it.

I figure I have to have a loop that with add one until it equals the initial input, and that would be the way to setup the rows.

But I'm not sure how to break the rows up in a backwards fashion from what I have started with...

I did use unneeded } but I feel it separates the code and I can remove them later.

I figure I have to have a loop that with add one until it equals the initial input, and that would be the way to setup the rows.

But I'm not sure how to break the rows up in a backwards fashion from what I have started with...

I did use unneeded } but I feel it separates the code and I can remove them later.

IF you know of a better way to do it let me know, I know there are easier ways but I just started here.

IF you know of a better way to do it let me know, I know there are easier ways but I just started here.