Nested looping code

Need help writing a code which creates this structure. I understand how to write the loop decreasing numerically from 44 to 0, but dont understand how to integrate that into this required shape or keep the 0's before the #... help!

(what its supposed to look like):


0044
0043 0042
0041 0040 0039
0038 0037 0036 0035
0034 0033 0032 0031 0030
0029 0028 0027 0026 0025 0024
0023 0022 0021 0020 0019 0018 0017
0016 0015 0014 0013 0012 0011 0010 0009
0008 0007 0006 0005 0004 0003 0002 0001 0000
I guess it's a matter of whether you can recognise patterns or not.

1
2
3
4
5
6
7
8
9
10
const int rows{ 9 }, digits{ 4 };
int initial{ 44 };

std::cout << std::setfill( '0' );
for( int i{ 1 }; i <= rows; i++ ) {
    for( int j{}; j < i; j++, initial-- )
	    std::cout << std::setw( digits ) << initial << " ";

	std::cout << "\n";
}
thank you!!
Topic archived. No new replies allowed.