Program to print an array with the same number of rows and columns with descending order [closed]

-3

I need to know what a program would look like to print an array in the same way below, where the bottom line will always subtract 1 from the top number. I really tried to make a code but I did not know where to start, so I came to ask for a help here.

 6 5 4 3  \ Caso o usuário digite 4 linhas
 5 4 3 2
 4 3 2 1
 3 2 1 0


 4 3 2   \ Caso o usuário digite 3 linhas
 3 2 1 
 2 1 0

 2 1     \ Caso o usuário digite 2 linhas
 1 0
    
asked by anonymous 18.11.2018 / 02:25

1 answer

-1

If I understand correctly, the code below solves your problem. Would that be it?

If you need help understanding the code, just let us know.

#include <iostream>
using namespace std;

int main()
{
    int squareMatrixOrder;
    cout << "Enter the square matrix order: \n";
    cin >> squareMatrixOrder;

    int startNumber = (squareMatrixOrder * 2) - 2;

    for( int row = squareMatrixOrder; row > 0 ; row-- ) {
        int currentNumber = startNumber;
        for( int column = 0; column < squareMatrixOrder; column++ ) {
            cout << currentNumber-- << " ";
        }
        startNumber--;
        cout << endl;
    }
}
    
18.11.2018 / 05:47