#K67677. Matrix Rotation
Matrix Rotation
Matrix Rotation
You are given a two-dimensional matrix \(A\) with dimensions \(n \times m\). Your task is to compute the matrix rotated by 90° clockwise.
Rotation Details: For a given matrix \[ A = \begin{bmatrix} a_{1,1} & a_{1,2} & \cdots & a_{1,m} \\ a_{2,1} & a_{2,2} & \cdots & a_{2,m} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n,1} & a_{n,2} & \cdots & a_{n,m} \end{bmatrix} \] after rotation, the output matrix \(B\) will have dimensions \(m \times n\) and is defined by \[ B_{i,j} = A_{n-j+1,i}. \] Write a program that reads from stdin and prints the rotated matrix to stdout.
inputFormat
The first line contains two integers \(n\) and \(m\) separated by a space, which represent the number of rows and columns of the matrix respectively. The following \(n\) lines each contain \(m\) integers separated by spaces, representing the elements of the matrix.
outputFormat
Output the rotated matrix with \(m\) rows and \(n\) columns. Each row should be printed on a new line with the elements separated by a single space.
## sample3 3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>