#C13536. Rotate Matrix

    ID: 43085 Type: Default 1000ms 256MiB

Rotate Matrix

Rotate Matrix

You are given a square matrix and your task is to rotate the matrix by 90° clockwise.

The input begins with an integer \( n \) representing the size of the matrix. If \( n > 0 \), the next \( n \) lines each contain \( n \) space-separated integers, representing the rows of the matrix. If \( n = 0 \), the matrix is empty and nothing should be output.

Mathematically, for an \( n \times n \) matrix \( A \), the rotated matrix \( B \) is defined by the formula: \[ B[j][n-1-i] = A[i][j] \quad \text{for} \; 0 \leq i, j < n. \]

Output the rotated matrix in the same row-by-row format with each element separated by a single space.

inputFormat

The first line contains an integer \( n \), representing the size of the square matrix. If \( n > 0 \), it is followed by \( n \) lines, each containing \( n \) integers separated by spaces which represent the rows of the matrix.

outputFormat

Output the rotated matrix such that each row is printed on a new line and the numbers in each row are separated by a single space. For \( n = 0 \), output nothing.

## sample
3
1 2 3
4 5 6
7 8 9
7 4 1

8 5 2 9 6 3

</p>