#K71732. Matrix Rotation

    ID: 33597 Type: Default 1000ms 256MiB

Matrix Rotation

Matrix Rotation

You are given a square matrix A of size \(n \times n\). Your task is to rotate the matrix 90 degrees clockwise. That is, for every element \(A_{ij}\) in the matrix, its new position after a 90-degree clockwise rotation will be \(A'_{ji'}\) where \(i' = n - 1 - i\).

Task: Write a program that reads the matrix from the standard input, rotates it, and prints the rotated matrix to the standard output.

Example:

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

Output: 7 4 1 8 5 2 9 6 3

</p>

Note: All numbers in the matrix can be positive, negative, or zero.

inputFormat

The input consists of multiple lines. The first line contains a positive integer (n), the size of the square matrix. The next (n) lines each contain (n) space-separated integers representing the rows of the matrix.

outputFormat

The output should contain the rotated matrix. Each of the (n) lines should contain (n) space-separated integers representing the rows 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>