-
Notifications
You must be signed in to change notification settings - Fork 0
/
matrix-equal-or-not.c
64 lines (63 loc) · 1.1 KB
/
matrix-equal-or-not.c
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
#include<stdio.h>
#include<stdlib.h>
int main(){
int a[10][10],b[10][10],i,j,r1,c1,r2,c2,flag=1;
scanf("%d %d",&r1,&c1);
scanf("%d %d",&r2,&c2);
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<r2;i++)
{
for(j=0;j<c2;j++)
{
scanf("%d",&b[i][j]);
}
}
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
printf("%d",a[i][j]);
}
printf("\n");
}
for(i=0;i<r1;i++)
{
for(j=0;j<c1;j++)
{
printf("%d",b[i][j]);
}
printf("\n");
}
if(r1==c1&&r2==c2)
{
for(i=0;i<r1;i++)
{
for(j=0;j<c2;j++)
{
if(a[i][j]!=b[i][j])
{
flag=0;
break;
}
}
}
}
else
{
printf("matrix cannot be compared");
exit(1);
}
if(flag==1)
{
printf("two matrices are equal");
}else
{
printf("not equal");
}
}