Rotate a rectangle array

Report a typo

Given a rectangle array n×m in size. Rotate it by 90 degrees clockwise, by recording the result into the new array m×n in size.

Input data format

Input consists of the two numbers n and m, not exceeding 100, and then an array n×m in size.

Output data format

Output the resulting array. Separate numbers by a single space in the output.

Sample Input 1:

3 4
11 12 13 14
21 22 23 24
31 32 33 34

Sample Output 1:

31 21 11 
32 22 12 
33 23 13 
34 24 14
Write a program in Java 17
class Main {
public static void main(String[] args) {
// put your code here
}
}
___

Create a free account to access the full topic