#C8406. Matrix Rotation
Matrix Rotation
Matrix Rotation
You are given an \( n \times n \) matrix. Your task is to rotate the matrix 90 degrees clockwise. In other words, the element at position \( (i, j) \) in the original matrix will move to position \( (j, n-i-1) \) in the rotated matrix.
Example:
For \( n = 3 \) and the following matrix:
1 2 3 4 5 6 7 8 9
The rotated matrix will be:
7 4 1 8 5 2 9 6 3
inputFormat
The first line of input contains a single integer \( n \) representing the size of the matrix. The next \( n \) lines each contain \( n \) space-separated integers representing the rows of the matrix.
outputFormat
Output the rotated matrix. Each of the \( n \) lines should contain \( n \) space-separated integers representing each row of the rotated matrix.
## sample3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>