Diagonal exchange
Problem
Given a square array. Swap the elements on the main and side diagonals, with each element remaining in the same column (i.e., in each column, you need to swap the element on the main diagonal and on the side diagonal).
Input
The input is the number
n
- size of the square array (n <= 10). Next come
n
lines of
n
numbers each - array elements.
Imprint
Display the array after conversion.
Example
# |
Input |
Output |
1 |
3
1 2 3
4 5 6
7 8 9
| 7 2 9
4 5 6
1 8 3
|