#C14947. Matrix Transposition
Matrix Transposition
Matrix Transposition
This problem requires you to compute the transpose of a given matrix.
Given a matrix \(A\) with \(n\) rows and \(m\) columns, its transpose \(A^T\) is an \(m \times n\) matrix where the element at the \(i\)-th row and \(j\)-th column of \(A^T\) is \(A_{j,i}\). For example, if
[ A = \begin{bmatrix} 1 & 2 & 3 \ 4 & 5 & 6 \end{bmatrix}, \quad ]
then its transpose is
[ A^T = \begin{bmatrix} 1 & 4 \ 2 & 5 \ 3 & 6 \end{bmatrix}. ]
</p>If the matrix is empty (i.e. \(n = 0\) or \(m = 0\)), you should output nothing.
inputFormat
The input is read from the standard input (stdin) in the following format:
- The first line contains two integers \(n\) and \(m\) (number of rows and columns respectively).
- The next \(n\) lines each contain \(m\) space-separated integers representing the elements of the matrix.
outputFormat
The output should be printed to stdout, representing the transposed matrix. The transposed matrix will have \(m\) rows and \(n\) columns. Print each row on a new line, and separate the integers in the same row by a single space.
If the matrix is empty, output nothing.
## sample2 2
1 2
3 4
1 3
2 4
</p>