This is the code I tried but I need a pattern like this:
1 2 3 4
2 3 4
3 4
4
Please help me with the code.
#include <iostream>
using namespace std;
int main()
{
int rows;
cout << "Enter number of rows: ";
cin >> rows;
for(int i = rows; i >= 1; --i)
{
for(int j = 1; j <= i; ++j)
{
cout << j << " ";
}
cout << endl;
}
return 0;
}
The code currently prints:
1 2 3 4
1 2 3
1 2
1