Special Number Triangle

I know how to write a program that displays the following:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9 10

But how can I edit this code to make it count down like this?
10
10 9
10 9 8
10 9 8 7
etc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
int i, j;
for (i = 1; i <= 10; i++)
{
  for (j = 1; j <= i; j++)
  {
    cout << j << " ";
  }
  cout << endl;
}
}
Last edited on
Switch the direction of the second for loop (from ascending to descending).
What exactly would that look like in my code?
Instead of j++ you would use j--, then fill in the starting and stopping positions accordingly.
Topic archived. No new replies allowed.