#C12402. Rotate Matrix 90 Degrees Clockwise
Rotate Matrix 90 Degrees Clockwise
Rotate Matrix 90 Degrees Clockwise
Given a square matrix of size \(n \times n\), your task is to rotate the matrix by 90 degrees clockwise. The rotation must be done in-place, meaning you should not use extra space for another matrix. This is a common problem that tests your understanding of matrix manipulation and in-place algorithms.
Example:
For a \(3 \times 3\) matrix:
1 2 3 4 5 6 7 8 9
The rotated matrix should be:
7 4 1 8 5 2 9 6 3
inputFormat
The first line of input contains an integer \(n\) representing the size of the matrix. The following \(n\) lines each contain \(n\) space-separated integers representing the rows of the matrix.
outputFormat
Output the rotated matrix, where each of the \(n\) lines contains \(n\) space-separated integers representing the rotated row.
## sample3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>