-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEqMat.java
More file actions
64 lines (60 loc) · 1.36 KB
/
Copy pathEqMat.java
File metadata and controls
64 lines (60 loc) · 1.36 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
61
62
63
64
import java.util.*;
public class EqMat
{
int a[][],m,n;
EqMat(int mm,int nn)
{
m=mm;
n=nn;
a=new int[m][n];
}
void readarray()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the elements of array");
for(int r=0;r<m;r++)
{
for(int c=0;c<n;c++)
a[r][c]=sc.nextInt();
}
}
int check(EqMat P,EqMat Q)
{
if((P.m==Q.m)&&(P.n==Q.n))
{
for(int r=0;r<m;r++)
{
for(int c=0;c<n;c++)
if(P.a[r][c]!=Q.a[r][c])
return 0;
}
}
else
return 0;
return 1;
}
void print()
{
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
System.out.print(a[i][j]+"\t");
System.out.println("\n");
}
System.out.println("\n\n\n");
}
public static void main(int a,int b,int c,int d)
{
EqMat ob=new EqMat(a,b);
EqMat ob1=new EqMat(c,d);
EqMat ob2=new EqMat(a,b);
ob.readarray();
ob1.readarray();
if(ob2.check(ob,ob1)==1)
System.out.println("Both matrices equal");
else
System.out.println("Both matrices not equal");
ob.print();
ob1.print();
}
}