#C7434. Matrix Transposition
Matrix Transposition
Matrix Transposition
You are given a matrix of size \(N \times M\). Your task is to compute the transpose of the matrix, i.e. produce a matrix of size \(M \times N\) where the element at the \(i\)-th row and \(j\)-th column in the original matrix becomes the element at the \(j\)-th row and \(i\)-th column in the transposed matrix.
Input Format: The first line contains two integers \(N\) and \(M\) indicating the number of rows and columns of the matrix. Then, there are \(N\) lines each consisting of \(M\) integers. It is guaranteed that if \(N = 0\) or \(M = 0\) the matrix is empty and nothing should be printed.
Output Format: Output the transposed matrix in \(M\) lines, each line containing \(N\) space-separated integers.
For example, given the matrix:
[ \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix} ]
its transpose is:
[ \begin{bmatrix} 1 & 4 \ 2 & 5 \ 3 & 6 \end{bmatrix} ]
</p>inputFormat
The first line of input contains two integers \(N\) (number of rows) and \(M\) (number of columns).
This is followed by \(N\) lines, each containing \(M\) integers separated by spaces.
outputFormat
Output the transposed matrix where each of the \(M\) lines contains \(N\) integers separated by spaces.
## sample2 3
1 2 3
4 5 6
1 4
2 5
3 6
</p>