十字鍊錶 稀疏矩陣

2021-06-27 06:12:27 字數 664 閱讀 4743

#include#includetypedef struct olnode

olnode, *olink;

typedef struct// 行和列煉表頭指標向量基址,由creatsmatrix_ol()分配

crosslist;

// 初始化m(crosslist型別的變數必須初始化,否則建立、複製矩陣將出錯)

bool initsmatrix(crosslist &m)

//建立稀疏矩陣

bool createsmatrix(crosslist &m,int m,int n,int t)

else // 尋查在行表中的插入位置

//再來列的

if(m.chead[j] == null || m.chead[j]->i > i)

else // 尋查在列表中的插入位置

}return true;

}bool checksmatrix(crosslist &m,int i,int j,int &e)

// 按行或按列輸出稀疏矩陣m

bool printsmatrix(crosslist &m)

printf("\n");

}return true;

}int main()

稀疏矩陣相加(十字鍊錶儲存)

標頭檔案 linklist.h inte ce for the linklist class.if defined afx linklist h 0f0cca3e d836 4bb4 9030 b548558fc57e included define afx linklist h 0f0cca3e ...

稀疏矩陣的建立 十字鍊錶

一 概念 既然要用鍊錶節點來模擬矩陣中的非零元素,肯定需要如下5個元素 row,col,val,down,right 其中 row 矩陣中的行。col 矩陣中的列。val 矩陣中的值。right 指向右側的乙個非零元素。down 指向下側的乙個非零元素。現在我們知道單個節點該如何表示了,那麼矩陣中同...

稀疏矩陣十字鍊錶表示法

稀疏矩陣十字鍊錶表示法和基本運算 include include define m 3 矩陣行 define n 3 矩陣列 define max m n m n 矩陣行列較大者 typedef int elemtype typedef struct mtxn tag matnode 十字鍊錶型別定...