#K36717. Matrix Rotation
Matrix Rotation
Matrix Rotation
You are given an \( n \times n \) matrix. Your task is to rotate the matrix by 90° clockwise.
The rotation must be performed such that every element moves to its correct position in the rotated matrix. For an element \( a_{ij} \) in the original matrix, its new position in the rotated matrix becomes \( a_{j, n-i-1} \).
Note: The input matrix is always a square matrix.
inputFormat
The first line of input contains a single integer \( n \) representing the dimension 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 as the input, i.e. \( n \) lines each containing \( n \) space-separated integers. This matrix is the original matrix rotated 90° clockwise.
## sample3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>