#C239. Matrix Rotation
Matrix Rotation
Matrix Rotation
You are given an (N \times N) matrix. Your task is to rotate the matrix by 90° clockwise in-place. The rotation should be performed without using an extra matrix, i.e., you should modify the input matrix directly.
For example, given the matrix:
(\begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \ 7 & 8 & 9 \end{bmatrix})
The rotated matrix would be:
(\begin{bmatrix} 7 & 4 & 1 \ 8 & 5 & 2 \ 9 & 6 & 3 \end{bmatrix})
Implement the rotation and print the resulting matrix.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (N), representing the dimension of the square matrix. The next (N) lines each contain (N) space-separated integers representing the matrix.
outputFormat
Output the rotated matrix to standard output (stdout) with (N) lines, where each line contains (N) space-separated integers. There should be no extra spaces at the end of each line.## sample
3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>