Write a program that rearranges the side-diagonal elements of a square matrix in descending order, starting from the upper right corner. The remaining elements of the matrix should remain in place.
Input
The first line contains a single number N
the size of a square matrix ( 1 <= N <= 100 ). The following N
lines contain matrix rows, each – by N natural numbers separated by spaces.
Output
The program should output the resulting matrix, in which the elements of the main diagonal are arranged in ascending order.
Examples
# |
Input |
Output |
1 |
5
12 4 8 13 13
1 12 1 4 15
2 3 5 2 3
6 5 13 12 14
14 9 15 4 12
|
12 4 8 13 14
1 12 1 13 15
2 3 5 2 3
6 5 13 12 14
4 9 15 4 12
|
Запрещенные операторы:sort