#C691. Rotate Matrix 90 Degrees Clockwise

    ID: 50722 Type: Default 1000ms 256MiB

Rotate Matrix 90 Degrees Clockwise

Rotate Matrix 90 Degrees Clockwise

Given a square matrix of integers, your task is to rotate the matrix by 90° clockwise. The transformation rule is such that an element at position \( (i,j) \) in the original matrix will move to position \( (j, n-1-i) \) in the rotated matrix, where \( n \) is the dimension of the square matrix.

For example, the following 3 × 3 matrix:

1 2 3
4 5 6
7 8 9

when rotated 90° clockwise becomes:

7 4 1
8 5 2
9 6 3

Solve the problem by reading the matrix from standard input and outputting the rotated matrix to standard output in the same format.

inputFormat

The input starts with an integer \( n \) (\( 1 \leq n \leq 100 \)), the size of the matrix. Following this, there are \( n \) lines, each containing \( n \) space-separated integers representing the matrix rows.

outputFormat

Output the rotated matrix in \( n \) lines, where each line contains \( n \) integers separated by a single space. Ensure that no extra spaces or newline characters are printed.

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

8 5 2 9 6 3

</p>