#include “stdio.h”
#include “conio.h”
void main()
{
int a[10][10],i,j,m,n,c=0,v=0;
clrscr();
printf("\n Enter The Value of rows:");
scanf("%d",&m);
printf("\n Enter The Value of columns:");
scanf("%d",&n);
printf("\n Enter The Value For Matrix\n");
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
scanf("%d",&a[i][j]);
}
printf("\nRows\tColumns\tValues");
for(i=1;i<=m;i++)
{
for(j=1;j<=n;j++)
if(a[i][j]==0)
c++;
else
{
v++;
printf("\n%d\t%d\t%d",i,j,a[i][j]);
}
}
}
if(c>v)
printf("\nThe Number Zeros Is:%d",c);
getch();
}
Output will be
Enter The Value of rows:3
Enter The Value of columns:3
Enter The Value For Matrix
0 1 0
2 0 0
0 3 1
Rows Columns Values
1 2 1
2 1 2
3 2 3
3 3 1
The given matrix is sparse matrix.
The Number Zeros Is:5
Google Ads
Monday, May 25, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment