Working with loops to output justified patterns?

Hi everyone! I am having trouble with a class assignment (Intro to C++) where I am supposed output three different patterns using loop statements. The patterns where: a square, a upside down triangle, and a right justified triangle. I got the first two ok, but am having a difficult time getting the last one to be right justified. Can anyone help me with this. I have place the manipulator just about everywhere I can think of in the code without the desired result. I need to output:
       *
     * *
   * * *
 * * * *

My question is, while working with loops, how do I justify this pattern to the right, or am I just going about this the completely wrong way?

Here is where I stopped:

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
#include <iostream>
#include <iomanip>

using namespace std;
int main()
{
    int x, y, num;

    cout << "Please enter a posative number to determine \n"
         << "how large you would like the shape to be. ";
    cin  >> num;
    

    for ( x = 1 ; x <= num ; x++ )
    { 
        cout << setw(num * 2);
        for ( y = 1 ; y <= x ; y++ )
            cout << "* ";
        cout << endl;
    }

system ("Pause");

return 0;
}
for m from 1 to len+1
   for n from 0 to len-m, print ' '
   for o from 0 to m, print '*'
@hamsterman

wow, that sure helped!
Topic archived. No new replies allowed.