int n, o = 2;
cout << "n="; cin >> n;
for(int i = 1; i <= n; i++) {
for(int j = n; j >= i; j--) {
cout << o << " ";
o += 2;
}
cout << endl;
}
My code outputs (when n is 4)
2 4 6 8
10 12 14
16 18
20
How would I align it to output this?
2 4 6 8
10 12 14
16 18
20
I am trying to align the output to the right in such a way that the numbers are aligned one below another (for example the 4 is aligned to the space between the 10 and 12 and I want to align it to 10). Thanks.
std::rightandstd::setw