#K9486. Matrix Rotation

    ID: 38735 Type: Default 1000ms 256MiB

Matrix Rotation

Matrix Rotation

You are given an \(n \times n\) matrix. Your task is to rotate the matrix 90° clockwise. In other words, for each element in the matrix, the new position after rotation is determined such that the element originally at position \(A[i][j]\) will appear at position \(B[j][n-1-i]\).

Please read the matrix from the standard input and output the rotated matrix to the standard output. Make sure your solution can handle various test cases including small matrices and matrices with negative and large numbers.

inputFormat

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

outputFormat

Output the rotated matrix. Print \(n\) lines, where each line contains \(n\) space-separated integers representing the rows of the resulting matrix after a 90° clockwise rotation.

## sample
4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
13 9 5 1

14 10 6 2 15 11 7 3 16 12 8 4

</p>