#C543. Matrix Rotation by 90° Clockwise
Matrix Rotation by 90° Clockwise
Matrix Rotation by 90° Clockwise
You are given an \( n \times n \) matrix. Your task is to rotate the matrix 90° clockwise in place. This means that you should modify the input matrix such that after the rotation, the element originally at position \( (i, j) \) moves to position \( (j, n-i-1) \). The rotation should be performed without using extra space for another matrix.
Note: The rotation must be performed in place.
Example:
Input: 3 1 2 3 4 5 6 7 8 9</p>Output: 7 4 1 8 5 2 9 6 3
inputFormat
The first line of input contains an integer \( n \) indicating 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 in the same format: \( n \) lines where each line contains \( n \) space-separated integers. There should be no extra spaces at the end of any line.
## sample3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>