#C14776. Rotate Matrix 90° Clockwise
Rotate Matrix 90° Clockwise
Rotate Matrix 90° Clockwise
Given an (N \times N) matrix, your task is to rotate the matrix 90° clockwise in place. The rotation should be performed without using additional memory for another matrix.
For example, if the input matrix is:
1 2 3
4 5 6
7 8 9
After a 90° clockwise rotation, the matrix becomes:
7 4 1
8 5 2
9 6 3
Implement a program that reads the matrix from standard input, rotates it as described, and prints the rotated matrix to standard output. All operations must be done in place.
inputFormat
The first line of input contains an integer (N) representing the size of the matrix. If (N = 0), then the matrix is empty and nothing should be printed. The next (N) lines each contain (N) integers separated by spaces representing the rows of the matrix.
outputFormat
Output the rotated matrix to standard output. Each row of the matrix should be printed on a new line with its elements separated by a single space. If the input matrix is empty (i.e., (N = 0)), do not print anything.## sample
3
1 2 3
4 5 6
7 8 9
7 4 1
8 5 2
9 6 3
</p>