Expand|Select|Wrap|Line Numbers
- for (int i = 1; i <= 6; i++)
- {
- for (int j = 1; j <= i; j++)
- cout << setw(3) << j;
- cout << endl;
- }
1
1 2
1 2 3
1 2 3 4 5
1 2 3 4 5 6
Expand|Select|Wrap|Line Numbers
- for (int i = 6; i >= 1; i--)
- {
- for (int j = 1; j <= i; j++)
- cout << setw(3) << j;
- cout << endl;
- }
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
as what i understand
Expand|Select|Wrap|Line Numbers
- for (int i = 6; i >= 1; i--)
- {
- cout << endl;
- }
and
Expand|Select|Wrap|Line Numbers
- for (int j = 1; j <= i; j++)
- cout << setw(3) << j;
my question here is what should i change or added he code above so that my output will display the pattern below:
__________1
________2_1
______3_2_1
____4_3_2_1
__5_4_3_2_1
6_5_4_3_2_1
and
1_2_3_4_5_6
__1_2_3_4_5
____1_2_3_4
______1_2_3
________1_2
__________1
note: _ is space
how can i print out my numbers that the alignment shift to the right? should i add space(" ") using if else loop for cout? or i might have a better solution??