資料結構 順序表總結(c )

2021-10-09 19:22:40 字數 1317 閱讀 5924

#include

using

namespace std;

#define maxsize 10000

typedef

int elemtype;

typedef

struct

sqlist;

elemtype initlist

(sqlist &l)

;//建立乙個空的順序表

elemtype creatlist

(sqlist &l)

;//建立含有n個元素的順序表

elemtype getdata

(sqlist &l,

int i, elemtype &e)

;//順序表中取值 o(l)

elemtype printlist

(sqlist &l)

;//順序表的列印

elemtype locatedate

(sqlist &l, elemtype e)

;//在順序表中查詢,並返回位置

elemtype insertlist

(sqlist &l,

int i, elemtype e)

;//在順序表第i個位置插入元素 o(n)

elemtype deletedate

(sqlist &l,

int i)

;//在順序表中刪除第i個元素 o(n)

intmain()

elemtype initlist

(sqlist &l)

//建立乙個空的順序表

elemtype creatlist

(sqlist &l)

//建立含有n個元素的順序表

elemtype getdata

(sqlist &l,

int i, elemtype &e)

//順序表中取值

elemtype printlist

(sqlist &l)

//順序表的列印

elemtype locatedate

(sqlist &l, elemtype e)

//在順序表中查詢,並返回位置

return0;

}elemtype insertlist

(sqlist &l,

int i, elemtype e)

//在順序表第i個位置插入元素

elemtype deletedate

(sqlist &l,

int i)

//在順序表中刪除第i個元素

C 資料結構 順序表

迴圈後面加 是個好行為,不然很容易犯低階錯誤 導致乙個變數的位置放錯了,看了很久沒看出bug 順序表 include includeusing namespace std const int maxsize 25 typedef struct seqlist int main cout endl r...

C 資料結構 順序表

順序表,顧名思義儲存在計算機指定記憶體區域的一塊連續的儲存結構,跟我們一起排隊做廣播體操的那種方式 儲存物理結構 物理記憶體空間上是連續的 儲存邏輯關係 儲存值之間的關係為一對一 使用場景 一般訪問資料量比較大,新增和刪除操作不頻繁的資料 那麼我們這裡實現的語言是用的c 對於線性表的一些特性我們這裡...

C資料結構 順序表

1.定義動態順序表 typedef struct seqlist seqlist 2.順序表基礎功能實現 初始化 void init seqlist p,int capacity 摧毀 void destory seqlist p 擴容 void checkcapacity seqlist p in...