#C10508. Rotate Matrix

    ID: 39721 Type: Default 1000ms 256MiB

Rotate Matrix

Rotate Matrix

Given an \(n\times n\) matrix, rotate it 90° clockwise. The rotation should be performed in-place if possible. In other words, after rotating the matrix, the first row becomes the last column, the second row becomes the second-to-last column, and so on.

Your task is to implement this transformation and print the rotated matrix.

inputFormat

The input begins with an integer (n) ((1 \le n \le 100)), the size of the matrix. The following (n) lines each contain (n) integers separated by spaces, representing the rows of the matrix.

outputFormat

Output the resulting matrix after it has been rotated 90° clockwise. Each of the (n) lines should contain (n) integers separated by a single space.## sample

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

8 5 2 9 6 3

</p>