Problem

1 /7


square matrix

Theory Click to read/hide

Square matrices

Let the matrix A contain N rows and the same number of columns. Such matrices are called square.
Square matrices have main and secondary diagonals.
 
Main diagonal - the diagonal that goes from the top left corner to the bottom right corner.
Side diagonal- goes from upper right corner to lower left corner.

Then, to iterate over all elements on the main diagonal, one loop is enough:
pseudocode:
for i from 0 to N-1
     working with A[i][i]

The same loop can iterate over the elements of the secondary diagonal.
For elements on the side diagonal, the sum of the row and column indices is constant and equals N-1.
pseudocode:
for i from 0 to N-1
     working with A[i][N-1-i]

To process all elements located on the main diagonal and below it, you need a nested loop:
- line number changes from 0 to N-1;
- column number from 0 to i.
pseudocode:
for i from 0 to N-1
  for j from 0 to i
     working with A[i][j]

Problem

Given a number n. Create a two-dimensional array of size nxn and fill it according to the following rule. The numbers 0 should be written on the main diagonal. On the two diagonals adjacent to the main one, the numbers 1. On the next two diagonals, the numbers 2 etc.

Input
The input is a single number n (n<=10).

Imprint
Display the completed matrix.
 
Example
# Input Output
1 5 0 1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
4 3 2 1 0