-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathClockwise_Rotate.java
More file actions
39 lines (39 loc) · 1.01 KB
/
Clockwise_Rotate.java
File metadata and controls
39 lines (39 loc) · 1.01 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
import java.util.*;
class Clockwise_Rotate
{
public static void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number of Rows");
int r=sc.nextInt();
System.out.println("Enter the number of Columns");
int c=sc.nextInt();
int arr[][]=new int[r][c];
System.out.println("Enter the elements of Matrix");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
arr[i][j]=sc.nextInt();
}
}
System.out.println("Input Matrix Is:");
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
{
System.out.print(arr[i][j]+" ");
}
System.out.println("");
}
System.out.println("Matrix After Rotation Is:");
for(int j=0;j<c;j++)
{
for(int i=r-1;i>=0;i--)
{
System.out.print(arr[i][j]+"\t");
}
System.out.println(" ");
}
}
}