#K35492. Transpose a Square Matrix
Transpose a Square Matrix
Transpose a Square Matrix
You are given a non-empty square matrix and your task is to compute its transpose. The transpose of a matrix ( A ) is another matrix ( A^T ) defined by ( A^T_{ij} = A_{ji} ). In this problem, the matrix is provided via standard input and you must print the transposed matrix to standard output. If the matrix is empty or not square (i.e. the number of elements in any row does not equal the number of rows, or the dimension is non-positive), output the string ERROR
.
inputFormat
The input is given via standard input. The first line contains a single integer ( n ) indicating the number of rows (and columns) of the matrix. The following ( n ) lines each contain ( n ) space-separated integers representing the elements of each row of the matrix.
outputFormat
If the input is a valid non-empty square matrix, print its transpose. The output should consist of ( n ) lines, each containing ( n ) space-separated integers. Otherwise, print the string ERROR
.## sample
3
1 2 3
4 5 6
7 8 9
1 4 7
2 5 8
3 6 9
</p>