/*
Solution from learncpp.com
* Invert the nested loops example so it prints the following:
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
*
*/
#include <iostream>
usingnamespace std;
int main(){
int outer = 5;
// Since outer is being assign to 5 above the while loop
// The while loop will execute only if it's true, in this case
// outer is being decremented first by 1 so it's 4, than evaluated
// In the nested while loop, inner is assign to outer, so if
// the inner loop is true it will execute, and evaluate that #
// then decremented by 1
// Once loop or nested loop condition is false, it will exit both of the loops
// and execute the program
while(outer >=1)
{
int inner = outer;
while(inner >=1){
cout << " ";
cout << inner--;
}
cout << " \n";
--outer;
}
return 0;
}