#C7509. Transpose a Square Matrix
Transpose a Square Matrix
Transpose a Square Matrix
You are given a square matrix \( A \) of size \( n \times n \). Your task is to compute the transpose of the matrix. The transpose of a matrix is obtained by swapping its rows with its columns. In other words, the element at position \( (i, j) \) in the original matrix becomes the element at position \( (j, i) \) in the transposed matrix.
Input Format: The first line contains an integer \( n \) denoting the size of the matrix. The next \( n \) lines each contain \( n \) space-separated integers which represent the elements of the matrix.
Output Format: Print the transposed matrix in the same format: \( n \) lines with \( n \) space-separated integers on each line.
Example:
Input: 3 1 2 3 4 5 6 7 8 9</p>Output: 1 4 7 2 5 8 3 6 9
inputFormat
The first line contains an integer \( n \) representing the number of rows (and columns) of the square matrix. The next \( n \) lines each contain \( n \) space-separated integers representing the elements of the matrix.
outputFormat
Print the transposed matrix in \( n \) lines. Each line should contain \( n \) space-separated integers representing a row of the transposed matrix.
## sample3
1 2 3
4 5 6
7 8 9
1 4 7
2 5 8
3 6 9
</p>