题目描述:
思路:
先用三元顺序表存放稀疏矩阵typedef struct{
int row, col; int elem;} Elem;typedef struct{
int Row, Col, n; Elem data[10000];} Matrix;
接着行列号互换
T.Row = matrix.Col; T.Col = matrix.Row; T.n = matrix.n;
然后按列号优先的顺序,将原矩阵与转置矩阵T行列元素互换即可
if (T.n) {
q = 1; for (j = 0; j < matrix.Col; j++) for (p = 1; p <= matrix.n; p++) if (matrix.data[p].col == j) {
T.data[q].row = matrix.data[p].col;