-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmirror.java
58 lines (58 loc) · 1.16 KB
/
mirror.java
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.*;
class mirror
{
int m,x[][],y[][];
mirror(int m1)
{
m=m1;
x= new int[m][m];
y=new int[m][m];
}
Scanner sc=new Scanner (System.in);
void input()
{
System.out.print ("Enter Elements of Matrix");
for (int i=0;i<m;i++)
{
for (int j=0;j<m;j++)
x[i][j]=sc.nextInt();
}
}
void compute()
{
for (int j=0;j<m;j++)
{
for (int i=0;i<m;i++)
{
y[i][m-1-j]=x[i][j];
}
}
}
void display()
{
System.out.print ("Output");
for (int i=0;i<m;i++)
{
for (int j=0;j<m;j++)
{
System.out.print(y[i][j]+" ");
}
System.out.println();
}
}
public static void main(String args[])
{
Scanner sc=new Scanner (System.in);
System.out.println("Enter row and columns of matrix");
int m=sc.nextInt();
if(m >0)
{
mirror obj=new mirror(m);
obj.input();
obj.compute();
obj.display();
}
else
System.out.println("Invalid Input");
}
}