Link List Program Data Structure :: Array :: Sparse

/* check whether matrix is sparce or not */
#include<iostream.h>
void main()
{
int a[5][5],i,j,l=0,u=4,c1=0,c2=0;
cout<<“enter matrix\n”;
for(i=l;i<=u;i++)
{
for(j=l;j<=u;j++)
cin>>a[i][j];

}
for(i=l;i<=u;i++)
{
for(j=l;j<=u;j++)
{
if(a[i][j]==0)
c1=c1+1;
else
c2=c2+1;
}
}
if(c1>12)
cout<<“entered matrix is sparce”;
else
cout<<“entered matrix is not sparce”;
}

Share

About the Author

Akash Padhiyar

Visit Website

There are no comments yet, add one below.

Leave a Comment

Your email address will not be published. Required fields are marked *

*

Time limit is exhausted. Please reload CAPTCHA.