CiscoOA #32
Rotate Matrix
估计简单可在线判题
考点(AI 标注)原地数组
Rotate the given square matrix 90 degrees clockwise and output the rotated matrix; the direction is determined by the original example and cannot be changed to counterclockwise.
输入格式
The input is N M with N=M required, followed by N lines of M integers each. The original bounds only require a square matrix and give no numeric bounds; this site publicly adds 1≤N=M≤1000 and elements in −10^9..10^9.
输出格式
Output the rotated matrix as N lines, each with N space-separated integers; do not output the dimensions again.
样例 1
输入:
2 2
1 2
3 4
输出:
3 1
4 2
样例 2
输入:
1 1
7
输出:
7
样例 3
输入:
3 3
1 2 3
4 5 6
7 8 9
输出:
7 4 1
8 5 2
9 6 3
样例说明
The outputs of the three public examples are, in order: 3 1 / 4 2; 7; 7 4 1 / 8 5 2 / 9 6 3. Verified by independent enumeration or direct simulation.