← 返回 nvidia 的题目列表Transform an N x N Matrix by Swapping Rows and Columns (Matrix Transpose Variant)
类型:online_judge
Problem: N x N Matrix Row/Column Transformation (Likely Transpose)
Given an n x n integer matrix A, perform a row/column transformation and print the result.
Note: The original description only says “transform rows and columns”. The most common meaning is matrix transpose: output matrix B where B[i][j] = A[j][i]. If the interviewer meant rotation or another variant, follow the interview requirement.
Input Format
First line: integer n
Next n lines: n integers per line for matrix A
Output Format
Print the transformed matrix in n lines, n integers per line separated by spaces
Constraints
1 <= n <= 1000
Values fit in 32-bit signed integer
Example
Input:
3
1 2 3
4 5 6
7 8 9
Output (transpose):
1 4 7
2 5 8
3 6 9
Example
Input
1
5
Output
5