#C14488. Matrix Rotation
Matrix Rotation
Matrix Rotation
You are given an N×N matrix. Your task is to rotate the matrix by 90° clockwise. The rotation must be performed according to the formula:
$$\text{rotated}[j][n-1-i] = \text{matrix}[i][j]$$
for all indices \(0 \leq i,j \lt n\). For example, if the input matrix is:
1 2 3 4 5 6 7 8 9
then the rotated matrix is:
7 4 1 8 5 2 9 6 3
Implement your solution such that it reads the input from standard input (stdin) and writes the output to standard output (stdout).
inputFormat
The first line contains a single integer \(n\) representing the dimensions of the matrix. This is followed by \(n\) lines, each containing \(n\) space-separated integers, representing the rows of the matrix.
outputFormat
Output the rotated matrix in \(n\) lines where each line contains \(n\) space-separated integers. No extra spaces should appear at the end of each line.
## sample3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>