3、C程序中,i,j,k均从0开始)(2)调试程序与运行。对称矩阵存储下三角部分即i>=j。对称矩阵为3,9,1,4,79,5,2,5,81,2,5,2,44,5,2,1,77,8,4,7,9.页脚.参考程序如下:#include#defineN5intmain(){intupper[N][N]={{3,9,1,4,7},{9,5,2,5,8},{1,2,5,2,4},{4,5,2,1,7},{7,8,4,7,9}};/*对称矩阵*/introwMajor[15];/*存储转换数据后以行为主的数组*/intIndex;/*数组的索引值*/inti,j;print
4、f("Twodimensionaluppertriangulararray:");for(i=0;i=j)/*下三角元素进行存储*/{Index=i*(i+1)/2+j;/*ij与index的转换*/rowMajor[Index]=upper[i][j];}printf("RowMajoronedimensionalarray:
5、n");for(i=0;i<15;i++)/*输出转换后的一维数组*/printf("%3d",rowMajor[i]);printf("");return1;}2、完成程序exp5_2.c,实现稀疏矩阵的三元组表存储及稀疏矩阵的转置。调试并给出结果:补充完整程序,运行稀疏矩阵的一般转置算法;完成稀疏矩阵的快速转置算法,并修改主函数的转置调用算法,验证快速转置算法的正确性。.页脚.exp5_2.c部分代码如下:#include#defineMAXSIZE20/*非零元素个数最大值*/typedefintElemType;typedefstruct{int
6、i,j;ElemTypee;}Triple;typedefstruct{Tripledata[MAXSIZE+1];/*三元组表,data[0]不用*/intmu,nu,tu;/*矩阵的行数、列数、非零元个数*/}TSMatrix;voidTransposeSMatrix(TSMatrix*T,TSMatrix*M);/*一般转置算法*/voidFastTransposeSMatrix(TSMatrix*M,TSMatrix*T);/*快速转置算法*/intmain(){inti,j,k,q,col,p;inttemp[6][7]={{0,12,9,0,0,0,0},/*稀疏
7、矩阵*/.页脚.{0,0,0,0,0,0,0,},{-3,0,0,0,0,14,0},{0,0,24,0,0,0,0},{0,18,0,0,0,0,0},{15,0,0,-7,0,0,0},};TSMatrixT,M;M.mu=6;M.nu=7;M.tu=0;k=1;for(i=0;i