#C4644. Matrix Rotation by 90 Degrees Clockwise

    ID: 48205 Type: Default 1000ms 256MiB

Matrix Rotation by 90 Degrees Clockwise

Matrix Rotation by 90 Degrees Clockwise

Given a square matrix ( A ) of size ( n \times n ), you are required to rotate it by 90 degrees clockwise without using any built-in functions that directly accomplish this transformation. In other words, the element originally at position ( A[i][j] ) should move to position ( A'[j][n-i-1] ) in the rotated matrix. Your program should read the matrix from the standard input and output the rotated matrix to the standard output.

Example: If the input matrix is:

3
1 2 3
4 5 6
7 8 9

Then the correct output is:

7 4 1
8 5 2
9 6 3

inputFormat

The input is given via standard input in the following format:

The first line contains a single integer ( n ) indicating the number of rows (and columns) of the square matrix. The following ( n ) lines each contain ( n ) space-separated integers representing the matrix elements.

outputFormat

Output the rotated matrix to standard output. Each row of the matrix should be printed on a separate line with each element 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>