#C10371. Matrix Rotation
Matrix Rotation
Matrix Rotation
You are given an \(N \times N\) matrix. Your task is to rotate the matrix by 90° clockwise.
More formally, given a matrix \(A\) with elements \(a_{ij}\) (0-indexed), produce a matrix \(B\) such that:
[ B_{j, N-i-1} = A_{i,j} ]
for all valid \(i, j\). The rotated matrix should be printed row by row.
inputFormat
The input is read from standard input (stdin) and has the following format:
- An integer \(T\) denoting the number of test cases.
- For each test case:
- An integer \(N\) denoting the size of the matrix.
- Next \(N\) lines, each containing \(N\) space-separated integers representing the matrix rows.
outputFormat
Output the rotated matrices to standard output (stdout). For each test case, print each row of the rotated matrix on a new line with space-separated numbers. The outputs for consecutive test cases should be printed one after the other in the same order as the input.
## sample3
2
1 2
3 4
3
1 2 3
4 5 6
7 8 9
1
10
3 1
4 2
7 4 1
8 5 2
9 6 3
10
</p>