資料結構 演算法5 4 十字鍊錶 建立

2021-07-23 14:25:34 字數 1869 閱讀 8456

#include

#include

#include

#include

#define true 1

#define false 0

#define ok 1

#define error 0

#define infeasible -1

#define overflow -2

typedef

int status;

typedef

int elemtype;

typedef

struct olnode

olnode, *olink;

typedef

struct

crosslist; //十字鍊錶

/*******************************宣告部分****************************************/

status createsmatrix_ol(crosslist *m);

//建立十字鍊錶

status printsmatrix_ol(crosslist m);

//輸出十字鍊錶

/*******************************函式部分****************************************/

status createsmatrix_ol(crosslist *m)

//if

else//else

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

else//else

}//for

return ok;

}status createsmatrix_ol_auto(crosslist *m)

; int j_list[4] = ;

int e_list[4] = ;

if(m)

free(m);

m = 3;

n = 4;

t = 4;

m->mu = m;

m->nu = n;

m->tu = t;

if(!(m->rhead = (olink *)malloc((m+1)*sizeof(olink))))

exit(overflow);

if(!(m->chead = (olink *)malloc((n+1)*sizeof(olink))))

exit(overflow);

for(k = 0;k<= m->mu;k++) //初始化行列頭指標向量;各行列鍊錶為空鍊錶

m->rhead[k] = null;

for(k = 0;k<= m->nu;k++)

m->chead[k] = null;

for(k = 1;k<= m->tu;k++)//if

else//else

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

else//else

}//for

return ok;

}status printsmatrix_ol(crosslist m)

else

printf(" 0 ");

}printf("\n");

}}/*******************************主函式部分**************************************/

演算法5 4 建立稀疏矩陣的十字鍊錶 rar

crosslistarray.h include include define null 0 十字鍊錶的結構型別定義如下 typedef struct olnode olnode,olink typedef struct crosslist 建立稀疏矩陣的十字鍊錶的演算法 include cross...

資料結構 廣義表和十字鍊錶

概念 是線性表的推廣,可以儲存不同的資料結構,一般記為 ls a1,a2,an ai可以是單個元素也可以是廣義表。廣義表的資料結構是用鏈結構來實現的。幾個特殊的廣義表的長度 a 長度為0,是個空表,d e a,b,c,d 是乙個三元素的廣義表 e a,e a,a,a,是乙個長度2的廣義表。a 的長度...

十字鍊錶的建立

前幾天設計圖的儲存想當然的想到了十字鍊錶。今天發現在這次使用中,其實和鄰接表是一樣的,就準備換成鄰接表就把十字鍊錶記錄下來吧 十字鍊錶是乙個節點既有指向出度的邊,也有指向入度的邊。define max vertex num 60 struct arcbox 定義弧節點 struct vexnode ...