#include
#include
#include
//結構體
struct node
;//頭插
void
add_node
(struct node *head ,
int data)
//鏈結節點
new->next = head->next ;
new->prev = head ;
head->next = new ;
new->next->prev = new ;
}//遍歷節點
intshow_node
(struct node *head)
return-1
;}//尾插
intweicha_node
(struct node *head ,
int data)
//鏈結節點
p->next = new ;
new->prev = p ;
return-1
;}//刪除資料
void
dele_node
(struct node *head ,
int dele_data)
else
struct node *tmp = pos;
//回退上乙個節點資料
pos = pos->prev;
tmp->next =
null
; tmp->prev =
null
;//清空tmp
free
(tmp);}
pos = pos->next;}}
//查詢資料
void
fid_node
(struct node *head ,
int find_data)
p = p->next ;}if
(ret ==0)
}//修改資料
void
xiugai_node
(struct node *head ,
int old_data ,
int new_data)
p = p->next ;}if
(ret ==0)
}int
main
(void
)break
;case2:
break
;case3:
break
;case4:
break
;case5:
break
;case6:
break
;default
:printf
("先生您的輸入有誤\n");
break;}
}return0;
}
單鏈表的實現(增 刪 查 改功能)
標頭檔案函式 ifndef slistnode h define slistnode h typedef int datatype typedef struct slistnode slistnode slistnode buyslistnode datatype x void slistprint...
單鏈表的增刪查改
include includetypedef struct nodenode,linklist int num 查詢給定值的結點,返回結點指標 node findvalue char c,node head return head 查詢給定位置的結點的值 char findindex value n...
單鏈表的增刪查改
本篇部落格主要介紹c資料結構中的單鏈表有關的增刪查改操作,並且介紹列表的快慢指標,鍊錶的逆置和合併等用法,廢話不說直接上 pragma once include include include typedef int datetype typedef struct plistnode plistno...