Write a program that rearranges the elements of a square matrix located on the main diagonal in ascending order. 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
1 11 11 5 10
2 9 2 10 2
12 9 10 9 15
6 15 14 1 11
11 12 4 9 3
|
1 11 11 5 10
2 1 2 10 2
12 9 3 9 15
6 15 14 9 11
11 12 4 9 10
|
Запрещенные операторы:sort