#define maxsize 100
typedef struct
{
int i,j;
int e;
}triple;
typedef struct
{
triple data[maxsize+1]; /*yi fen pei nei cun*/
int mu,nu,tu;
}tsmatrix;
int creatmatrix(tsmatrix *a)
{
int i,j,n,e,mu,nu,tu;
printf("input she mu,nu,tu");
scanf("%d %d %d",&mu,&nu,&tu);
a->data[0].e=tu;
for(n=1;n<=tu;n++)
{
printf("input the i,j,e");
scanf("%d %d %d",&i,&j,&e);
a->data[n].i=i;a->data[n].j=j;a->data[n].e=e;
} printf("%d",a->data[1].e);
}
int printfmatrix(tsmatrix m)
{
int r,w,n; /* for(n=1;n<=m.tu;n++){
printf("%d",m.data[n].e); } */
for(r=1;r<=m.mu;r++)
{
for(w=1;w<=m.nu;w++)
{
for(n=1;n<=m.tu;n++)
{
if(r==m.data[n].i&&w==m.data[n].j)
printf("%4d",m.data[n].e);
printf("0");
}
}
printf("\n");
}
}
main()
{
tsmatrix a;
creatmatrix(&a);
printfmatrix(a);
}