#C2592. Rotate Matrix 90 Degrees Clockwise

    ID: 45925 Type: Default 1000ms 256MiB

Rotate Matrix 90 Degrees Clockwise

Rotate Matrix 90 Degrees Clockwise

Given a square matrix of size \( n \times n \) filled with integer values, rotate the matrix by 90 degrees clockwise.

Constraints:

  • \(1 \le n \le 100\)
  • \(-1000 \le matrix[i][j] \le 1000\)

The rotation is defined such that for every element in the matrix, its new position will be \( rotated[j][n-i-1] = matrix[i][j] \). Please note that input is given via standard input and output is expected via standard output.

inputFormat

The first line contains a single integer \( n \), representing the size of the matrix.

The next \( n \) lines each contain \( n \) space-separated integers, representing the rows of the matrix.

outputFormat

Output the rotated matrix in \( n \) lines. Each line should contain \( n \) space-separated integers.

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

8 5 2 9 6 3

</p>