#C1630. Matrix Rotation

    ID: 44857 Type: Default 1000ms 256MiB

Matrix Rotation

Matrix Rotation

Given an ( n \times n ) matrix, rotate the matrix by 90° clockwise in-place. The rotation must be performed by modifying the original matrix.

Note: Do not allocate another matrix for the rotation, you must perform the operation in-place. For example, if you are given the following matrix:

1 2 3
4 5 6
7 8 9

After rotation, the matrix should become:

7 4 1
8 5 2
9 6 3

Input will be provided via standard input and output should be printed to standard output.

inputFormat

The input starts with an integer ( n ) denoting the size of the matrix, followed by ( n ) lines each containing ( n ) space-separated integers representing the rows of the matrix.

outputFormat

Output the rotated matrix. Print ( n ) lines, each containing ( n ) space-separated integers that represent the matrix after a 90° clockwise rotation.## sample

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

8 5 2 9 6 3

</p>