#K82437. Matrix Rotation by 90 Degrees Clockwise
Matrix Rotation by 90 Degrees Clockwise
Matrix Rotation by 90 Degrees Clockwise
Given a square matrix \(A\) of size \(n \times n\), you are required to rotate it by 90 degrees clockwise. The rotation of the matrix is defined by the formula:
[ A'{j, n-i-1} = A{i,j} ]
where \(A'\) is the rotated matrix. Your task is to read the input matrix from stdin, perform the rotation, and print the resulting matrix to stdout.
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 contains an integer \(n\) representing the dimension of the matrix. Each of the next \(n\) lines contains \(n\) integers separated by spaces representing a row of the matrix.
outputFormat
Output the rotated matrix in the same format: \(n\) lines where each line contains \(n\) space-separated integers representing a 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>