#include<stdio.h>
#include<conio.h>
typedef struct
{
int row,col,val;
}smat;
void main()
{
smat a[10];
int i,j,k;
printf("Enter the total no of rows & total no of column");
scanf("%d%d",&a[0].row,&a[0].col);
printf("Enter the total no nof non zero element");
scanf("%d",&a[0].val);
for(i=1;i<=a[0].row;i++)
{
printf("Enter the row no& col no& value");
scanf("%d%d%d",&a[i].row,a[i].col,a[i].val);
}
printf("sparse matrix");
for(i=0;i<=a[0].val;++i)
printf("%d%d%d\n",a[i].row,a[i].col,a[i].val);
getch();
}
#include<conio.h>
typedef struct
{
int row,col,val;
}smat;
void main()
{
smat a[10];
int i,j,k;
printf("Enter the total no of rows & total no of column");
scanf("%d%d",&a[0].row,&a[0].col);
printf("Enter the total no nof non zero element");
scanf("%d",&a[0].val);
for(i=1;i<=a[0].row;i++)
{
printf("Enter the row no& col no& value");
scanf("%d%d%d",&a[i].row,a[i].col,a[i].val);
}
printf("sparse matrix");
for(i=0;i<=a[0].val;++i)
printf("%d%d%d\n",a[i].row,a[i].col,a[i].val);
getch();
}