#C6807. Rotate Matrix 90 Degrees Clockwise
Rotate Matrix 90 Degrees Clockwise
Rotate Matrix 90 Degrees Clockwise
You are given a matrix A of size \(n \times m\) and your task is to rotate it by 90 degrees clockwise. After rotation, the resulting matrix will have dimensions \(m \times n\).
Example:
If \(A = \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix}\), then the rotated matrix is \(\begin{bmatrix} 7 & 4 & 1 \\ 8 & 5 & 2 \\ 9 & 6 & 3 \end{bmatrix}\).
Write a program that reads the matrix from standard input and outputs the rotated matrix to standard output.
inputFormat
The first line contains two integers \(n\) and \(m\), the number of rows and columns of the matrix, respectively. Each of the following \(n\) lines contains \(m\) integers separated by spaces, representing the rows of the matrix.
outputFormat
Output the rotated matrix, which will have \(m\) rows and \(n\) columns. Each row should be printed on a new line with its elements separated by spaces.
## sample3 3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>