#K69542. Rotate Matrix 90 Degrees Clockwise

    ID: 33109 Type: Default 1000ms 256MiB

Rotate Matrix 90 Degrees Clockwise

Rotate Matrix 90 Degrees Clockwise

You are given a square matrix of size \( n \times n \). Your task is to rotate the matrix by 90 degrees clockwise. The rotation should be performed in such a way that every element moves to its new position according to the relation:

\( rotated[j][n-i-1] = matrix[i][j] \)

Note: The first line of input contains an integer \( n \), representing the dimensions of the matrix. The following \( n \) lines each contain \( n \) integers separated by spaces, representing the rows of the matrix.

After rotating the matrix, output the resulting matrix in the same format: each row on a new line with elements separated by a single space.

inputFormat

The input is given in stdin and has the following format:

  • The first line contains an integer \( n \) (the size of the matrix).
  • The next \( n \) lines each contain \( n \) space-separated integers representing the matrix.

outputFormat

Output to stdout the rotated matrix. Each of the \( n \) lines should contain \( n \) space-separated integers that represent a row of the rotated matrix.

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

8 5 2 9 6 3

</p>