雙向迴圈鍊錶(C語言)

2021-08-19 09:57:54 字數 3072 閱讀 5363

一、seqlist.h

#ifndef __seqlist__

#define __seqlist__

typedef int datatype;

typedef struct dclnode

node, *pnode;

void dclinit(pnode* pphead);  //雙向迴圈鍊錶的初始化

void dclpushback(pnode phead, datatype data);   //尾插

void dclpopback(pnode phead);    //尾刪

void dclpushfront(pnode phead, datatype data);    //頭插

void dclpopfront(pnode phead);    //頭刪

void dclinsert(pnode pos, datatype data);    //任意位置插入(包括頭插和尾插)

void dclerase(pnode pos);   //任意位置刪除(包括頭刪和尾刪)

void dcldestroy(pnode* pphead); //鍊錶銷毀

pnode dclfind(pnode phead, datatype data);   //鍊錶查詢

pnode dclbuynode(datatype data);   //建立節點

void dclprintlist(pnode phead);   //列印鍊錶

#endif

二、seqlist.c

三、test.c

#include

#include"seqlist.h"

int main()

{test();

system("pause");

return 0;

其實對於雙向迴圈鍊錶給大家的建議是多畫圖,搞懂每個結點的前驅和後繼到底是什麼?還有就是尾節點的後繼是頭結點,頭結點的前驅是尾節點。

雙向迴圈鍊錶 C語言

include include typedef int elemtype typedef int status typedef struct node listnode typedef listnode linklist 雙向迴圈鍊錶初始化 void initlist linklist l 判斷雙向...

C語言中的雙向迴圈鍊錶

單向鍊錶的構建,大家應該不陌生 include include define len sizeof struct node typedef struct node 建立乙個鏈式結構 tree void creatlist p2 next null 最後以null作為鍊錶的結束 ps 如果這裡是 p2...

C語言實現雙向迴圈鍊錶

list 雙向迴圈鍊錶,帶頭指標 struct list node 初始化頭指標 void list init head struct list node head 量表是否為空 是返回1,否返回0 int list is empty const struct list node head 鍊錶遍歷...