Upside down number pyramid

Hi, i was wondering how i could output an upside down pyramid with the size thats determined by the user.

for example: if a user inputs 4, the output would be:


543212345
x4321234x
x32123x
x212x
x1x

the x's are spaces
Last edited on
Like this?

543212345
4321234
32123
212
1
Anywho, this should work...


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
for (int i = 5; i >= 1; i--)
        {
            for (int j = i; j >= 1; j--)
            {
                std::cout << j;
            }
            
            for (int j = 2; j <= i; j++)
            {
                std::cout << j;
            }
            
            std::cout << "" std::endl;  //moves to the next line
            std::cout << " ";   //your space
        }
    }


EDIT** You of course will need to change the appropriate numbers to variables. I didn't want to take all the fun though.

Hambone
Last edited on
Topic archived. No new replies allowed.