#K85222. Rotate Matrix

    ID: 36594 Type: Default 1000ms 256MiB

Rotate Matrix

Rotate Matrix

Given a square matrix ( A ) of size ( n \times n ), rotate it by 90° clockwise. That is, produce a matrix ( B ) such that each element ( B[i][j] ) is equal to ( A[n - j - 1][i] ). This operation should be performed using standard input and output. The input is provided through stdin and the output should be printed to stdout.

For example, if the input matrix is:
1 2 3
4 5 6
7 8 9
After a 90° clockwise rotation, the output matrix is:
7 4 1
8 5 2
9 6 3

Use the relation ( B[i][j] = A[n - j - 1][i] ) in your solution.

inputFormat

The input is read from standard input (stdin). The first line contains an integer ( n ) (where ( n \geq 1 )), representing the size of the square matrix. The next ( n ) lines each contain ( n ) space-separated integers representing the rows of the matrix.

outputFormat

Print the rotated matrix to standard output (stdout). Each of the ( n ) lines should contain ( n ) space-separated integers, representing the rows of the new 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>