Pyramid of X's

This is my first time on the forum and I have a problem of printing a Pyramid of X's. The Pyramid should be 20 lines high.

I have to use three for loops to print the Pyramid in consul mode. The problem states that I have to use one outer for loop and two inner for loops to print the Pyramid. One inner for loop prints a space and the other inner for loop prints the X. The outer for loop steps down the screen from line to line.

Can anybody give me any more hints on how to print the Pyramid using the for loops?

I thought of using set(w) along with the inner loops but I can't see how they would be used together.
I don't want to just give you the answer, so I'm going to take stuff out so that you can work out what's going on and get it working.

So here it is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
	char letter = 'X';
	int loop = 20;
	int print = 1;

	for()
	{
		for()
		{
			std::cout << " ";
		}

		for()
		{
			std::cout << letter;
		}

		loop--;
		print += 2;
		std::cout << "\n";
	}


This is the structure that you've described.

This is the result I got from this code:
http://s749.photobucket.com/albums/xx132/Bigdave876/Websites/?action=view&current=Untitled.png
Last edited on
I for one love when teachers give you the wrong instructions in your assignment. A pyramid is a 3 dimensional shape that presents as a triangle from a front.isometric view and a square or triangle from a top.isometric view. Assuming your a**hole professor meant a triangle then Lynx876 has you off to a good start.

P.S.: Please forgive my demenor someone burnt the coffee maker this morning and I can't get a cup for another 15 mins...
Topic archived. No new replies allowed.