#K46937. Rotate Matrix by 90° Clockwise

    ID: 28087 Type: Default 1000ms 256MiB

Rotate Matrix by 90° Clockwise

Rotate Matrix by 90° Clockwise

You are given an N × N matrix. Your task is to rotate the matrix by 90° clockwise and output the result.

Input Format: The first line of input contains a single integer N, representing the size of the matrix. Each of the next N lines contains N space-separated integers representing the rows of the matrix.

Output Format: Output the rotated matrix with each row printed on a new line. The integers in each row should be space-separated.

Note: If the matrix is empty (N = 0), output nothing.

The rotation can be mathematically described by the formula:

rotated[j][N1i]=matrix[i][j]\text{rotated}[j][N-1-i] = \text{matrix}[i][j]

where \(0 \leq i,j < N\).

inputFormat

The input begins with an integer N (\(0 \leq N \leq 100\)) on a single line. If N is greater than 0, then follow N lines each containing N space-separated integers. These integers represent the rows of the matrix.

outputFormat

Output the rotated matrix. Each line represents a row in the rotated matrix where the numbers are separated by a space. If N is 0, output nothing.

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

8 5 2 9 6 3

</p>