-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMatRev.java
More file actions
60 lines (55 loc) · 1.05 KB
/
Copy pathMatRev.java
File metadata and controls
60 lines (55 loc) · 1.05 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.util.*;
public class MatRev
{
int arr[][],m,n;
MatRev(int mm,int nn)
{
m=mm;
n=nn;
arr=new int[m][n];
}
void fillarray()
{
Scanner sc=new Scanner(System.in);
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
arr[i][j]=sc.nextInt();
}
}
int reverse(int x)
{
int rev=0;
while(x>0)
{
rev=rev*10+(x%10);
x=x/10;
}
return rev;
}
void revMat(MatRev P)
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
arr[i][j]=reverse(P.arr[i][j]);
}
}
void show()
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
System.out.print(arr[i][j]+"\t");
System.out.println();
}
}
public static void main(int a,int b)
{
MatRev ob=new MatRev(a,b);
MatRev ob1=new MatRev(a,b);
ob.fillarray();
ob1.revMat(ob);
ob1.show();
}
}