-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathRotaion90.java
More file actions
40 lines (36 loc) · 1.21 KB
/
Rotaion90.java
File metadata and controls
40 lines (36 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.Scanner;
public class Rotaion90 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the length of row and column: ");
int row=sc.nextInt(),col=sc.nextInt(), num[][]= new int[row][col],unum[][]= new int[row][col];
// Input
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
System.out.println("Enter a number: ");
num[i][j]=sc.nextInt();
}
}
// Display
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
System.out.print(num[i][j]+"\t");
}
System.out.println();
}
System.out.println("Input Giver");
// rotating
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
unum[row-j-1][i]=num[i][j];
}
}
// Display
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
System.out.print(unum[i][j]+"\t");
}
System.out.println();
}
}
}