-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path40.c
47 lines (36 loc) · 819 Bytes
/
40.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
//C program to check sparse AND transpose matrix
//C program to check sparse AND transpose matrix
#include<stdio.h>
int main()
{
int m,n,i,j,count=0;
printf("Enter the no of rows :");
scanf("%d",&m);
printf("Enter the no of columns :");
scanf("%d",&n);
int a[m][n];
printf("Enter the no of elements :");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
if(a[i][j]==0)
count++;
}
printf("\n");
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",a[i][j]);
}
printf("\n");
}
if(count>(m*n/2))
printf("Matrix is Sparse");
else
printf("Matrix is not Sparse Matrix ");
return 0;
}