#K32892. Rotate Matrix 90 Degrees Clockwise
Rotate Matrix 90 Degrees Clockwise
Rotate Matrix 90 Degrees Clockwise
Given an N\times N matrix, rotate it by 90 degrees clockwise and output the resulting matrix.
The rotation transforms the matrix such that the element originally at position \( (i,j) \) moves to position \( (j, N-1-i) \), where \( N \) is the size of the matrix.
For example, given the matrix:
1 2 3 4 5 6 7 8 9
The output matrix after a 90 degree clockwise rotation will be:
7 4 1 8 5 2 9 6 3
If the matrix is empty (i.e., \( N=0 \)), then nothing should be printed.
inputFormat
The input is read from stdin and is formatted as follows:
- The first line contains an integer \( N \) representing the size of the matrix.
- If \( N > 0 \), the next \( N \) lines each contain \( N \) space-separated integers representing a row of the matrix.
outputFormat
Output the rotated matrix on stdout with each row on a new line. Within each line, the elements should be separated by a single space.
## sample3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>