#K96297. Matrix Rotation
Matrix Rotation
Matrix Rotation
You are given an n x n matrix. Your task is to rotate the matrix by 90° clockwise. After rotation, the element originally at position (i, j) moves to (j, n-1-i) as in the formula: $$a[i][j] \to a[j][n-1-i]$$.
You will read the matrix from standard input and should output the rotated matrix to standard output. Each row of the matrix should be printed on a new line with elements separated by a single space.
Note: The rotation must be performed for a square matrix of size n, where n is provided as the first input, followed by n lines each containing n integers.
inputFormat
The first line contains a single integer n
denoting the size of the matrix.
The next n
lines contain n
space-separated integers representing the rows of the matrix.
outputFormat
Output the rotated matrix. Each line of output should represent a row of the matrix after rotating 90° clockwise, with numbers separated by a single space.
## sample3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>