標頭檔案
list.h
原始檔#pragma once
#include
#include
#include
//帶頭雙向迴圈鍊錶增刪查改
typedef
int ltdatatype;
typedef
struct listnode
listnode;
listnode*
listcreate()
;//建立煉表頭結點
void
listdestory
(listnode* phead)
;//雙向鍊錶銷毀
void
listprint
(listnode* phead)
;//雙向鍊錶列印
void
listpushback
(listnode* phead, ltdatatype x)
;//雙向鍊錶尾插
void
listpopback
(listnode* phead)
;//雙向鍊錶尾刪
void
listpushfront
(listnode* phead, ltdatatype x)
;//雙向煉表頭插
void
listpopfront
(listnode* phead)
;// 雙向煉表頭刪
listnode*
listfind
(listnode* phead, ltdatatype x)
;//雙向鍊錶查詢
void
listinsert
(listnode* pos, ltdatatype x)
;//雙向鍊錶在pos的前面進行插入
void
listerase
(listnode* pos)
;//雙向鍊錶刪除pos位置的節點
list.c
test.c#include
"list.h"
listnode*
listcreate()
void
listdestroy
(listnode* phead)
free
(phead)
; phead =
null;}
void
listprint
(listnode* phead)
printf
("到煉表頭啦\n");
}listnode*
setlistnode
(ltdatatype x)
void
listpushback
(listnode* phead, ltdatatype x)
void
listpopback
(listnode* phead)
void
listpushfront
(listnode* phead, ltdatatype x)
void
listpopfront
(listnode* phead)
listnode*
listfind
(listnode* phead, ltdatatype x)
cur = cur->_next;
}return
null;}
void
listinsert
(listnode* pos, ltdatatype x)
void
listerase
(listnode* pos)
執行結果:#include
"list.h"
intmain()
C語言實現帶頭雙向迴圈鍊錶的介面
各函式功能如下 申請空間 listnode buylistnode ltdatatype x 初始化listnode listinit 指定位置插入 void listinsert listnode pos,ltdatatype x 頭插void listpushfront listnode phe...
C語言實現雙向迴圈鍊錶
list 雙向迴圈鍊錶,帶頭指標 struct list node 初始化頭指標 void list init head struct list node head 量表是否為空 是返回1,否返回0 int list is empty const struct list node head 鍊錶遍歷...
C語言實現雙向迴圈鍊錶
list 雙向迴圈鍊錶,帶頭指標 struct list node 初始化頭指標 void list init head struct list node head 量表是否為空 是返回1,否返回0 int list is empty const struct list node head 鍊錶遍歷...