#K66147. Transpose and Flatten a 4x4 Matrix
Transpose and Flatten a 4x4 Matrix
Transpose and Flatten a 4x4 Matrix
In this problem, you are given a 4x4 matrix represented by 16 integers provided in row-major order. Your task is to compute the transpose of the matrix and then output the flattened version of the original matrix.
Let \( A \) be a 4x4 matrix: \[ A = \begin{pmatrix} a_{11} & a_{12} & a_{13} & a_{14} \\ a_{21} & a_{22} & a_{23} & a_{24} \\ a_{31} & a_{32} & a_{33} & a_{34} \\ a_{41} & a_{42} & a_{43} & a_{44} \end{pmatrix} \] The transpose \( A^T \) is defined as: \[ A^T = \begin{pmatrix} a_{11} & a_{21} & a_{31} & a_{41} \\ a_{12} & a_{22} & a_{32} & a_{42} \\ a_{13} & a_{23} & a_{33} & a_{43} \\ a_{14} & a_{24} & a_{34} & a_{44} \end{pmatrix} \]
The flattened matrix is simply the original matrix listed in row-major order.
inputFormat
The input consists of 16 space-separated integers provided via standard input (stdin) representing a 4x4 matrix in row-major order.
outputFormat
The output should be printed to standard output (stdout). First, print the transposed matrix with each of its 4 rows on a new line, where numbers in a row are separated by a space. Then, print a single line containing the 16 integers of the original matrix (flattened in row-major order), separated by a space.
## sample1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
</p>