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
|