#K59262. Matrix Rotation

    ID: 30826 Type: Default 1000ms 256MiB

Matrix Rotation

Matrix Rotation

Given an \(n \times n\) matrix, your task is to rotate it by 90° clockwise.

Problem Statement: You are given a square matrix with \(n\) rows and \(n\) columns. Your task is to rotate the matrix in place by 90° in the clockwise direction. The rotation must be done in-place without using extra memory for another matrix.

Example: For the matrix below: \[ \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{bmatrix} \] The rotated matrix is: \[ \begin{bmatrix} 7 & 4 & 1 \\ 8 & 5 & 2 \\ 9 & 6 & 3 \end{bmatrix} \]

Note: If there are any formulas, they are represented using LaTeX format.

inputFormat

The first line contains an integer \(n\), the size of the matrix.

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

outputFormat

Output the rotated matrix, with each row printed on a new line and each element separated by a single space.

## sample
1
1
1

</p>