数据结构稀疏矩阵实验课程设计
/********function definition********/
int init_matrix(crosslist &one)
{//initialization
one.row_size=0;
one.colum_size=0;
one.non_zero_amount=0;
one.rhead=NULL;
one.chead=NULL;
return OK;
}//init_matrix
int creat_matrix(crosslist &one)
{//assignment
int i;//as count in the loop
element news,temp;
/*input row size ,colum size and non zero amount*/
printf("Input the row size of the matrix:");
scanf("%d",&one.row_size);
printf("Input the colum size of the matrix:");
scanf("%d",&one.colum_size);
printf("Input the non zero amount of the matrix:");
scanf("%d",&one.non_zero_amount);
/*allocate memory and the first memory not use*/
one.rhead=(element*)malloc(sizeof(element)*(one.row_size+1));
assert(one.rhead!=NULL);//assert have space
one.chead=(element*)malloc(sizeof(element)*(one.colum_size+1));
assert(one.chead!=NULL);
/*set all the pointer to NULL*/
for(i=1;i<=one.row_size;i++)
one.rhead[i]=NULL;
for(i=1;i<=one.colum_size;i++)
one.chead[i]=NULL;
printf("/**************************************/\n");
/*assignment*/
for(i=1;irow);
}while(news->row>one.row_size);
1