資料結構 順序表學習筆記

2022-09-17 05:48:13 字數 550 閱讀 4737

順序表操作

typedef struct seqlist

初始化listinitiate(l)

void listinitiate(seqlist *l)

獲取當前線性表的資料個數listlength(l)

void listlength(seqlist l)

插入資料元素listinsert(l,i,x) i插入的位置 x插入的資料

void listinsert(seqlist *l,int i,datatype x)

l->list[i]=x;

l->size++;

return 1;

}刪除資料元素listdelete(l,i,x) i插入的位置 *x指向被刪除的資料

void listdelete(seqlist *l,int i,datatype *x)

l->size--;

return 1;

}取元素 listget(l,i)

void listget(seqlist l,int i,datatype *x)else

}

資料結構學習筆記(一) 順序表

一般來說,由於順序表結點的位序從1開始,而c語言中向量的下標從0開始,若從下標為1的向量元素開始使用,使結點的位序和向量的下標一致,則處理會簡單一些,下標為0的元素不用或用作其它用途。include include using namespace std define maxsize 1024 結構...

資料結構學習筆記1順序表

初始化需要定義的三個要素 c語言 實現 typedef struct table table c語言 實現 table inittable t.length 0 t.size size return t c語言 實現 table addtable table t,int elem,int add i...

資料結構筆記之順序表

由上圖可以看出元素位址滿足以下關係 以圖書資料舉例,其型別定義如下 define maxsize 100 最大長度 typedef struct book 圖書結構型別 typedef struct sqlist 圖書表結構型別 3.1初始化 步驟 為l分配乙個預定義大小的陣列空間,elem指向這段...