![](https://i-blog.csdnimg.cn/blog_migrate/cb83f82883887d5c926cc1b4c5967f9f.jpeg)
![](https://i-blog.csdnimg.cn/blog_migrate/2d11022b6cdfd8a3e15d5249896fbe69.jpeg)
4> 双向循环链表尾插
doublelink insert_tail(doublelink head,datatype element)
82 {
83 //新节点
84 doublelink s=create_Node();
85 if(s==NULL)
86 return head;
87 s->data=element;
88 //空
89 if(head==NULL){
90 head=s;
91 return;
92 }
93
94 //多个节点
95 doublelink p=head;
96 while(p->next!=head)
97 {
98 p=p->next;
99
100 }
101 p->next=s;
102 s->priv=p;
103 //循环
104
105 s->next=head;
106 head->priv=s;
107 return head;
108
109
110 }
5> 双向循环链表头删
1 doublelink del_head(doublelink head)
112 {
113 //链表为空
114 if(head==NULL)
115 return NULL;
116 //只有一个节点
117 if(head->next==head)
118 { free(head);
119 head=NULL;
120 }
121 //多个节点
122 //找到尾节点
123
124 doublelink del=head;
doublelink tail = head->priv;
125 head=head->next;
126 head->priv=tail;
127 //循环
128
129 tail->next=head;
130 free(del);
131 del=NULL;
132 return head;
133 }
6> 双向循环链表尾删
doublelink del_tail(doublelink head)
136 {
137
138 if(head==NULL)
139 return NULL;
140 if(head->next==head)
141 {
142 free(head);
143 head=NULL;
144 return head;
145 }
146 doublelink p=head;
147 while(p->next->next!=head)
148 {
149 p=p->next;
150 }
151 doublelink del =p->next;
152 del->priv=NULL;
153 p->next=head;
154 head->priv=p;
155 free(del);
156 del=NULL;
157 return head;
158
159 }
![](https://i-blog.csdnimg.cn/blog_migrate/44a37fc12b2e0a6e32161f047816f46b.png)
思维导图
![](https://i-blog.csdnimg.cn/blog_migrate/7b35c5b5c991344395cb7a3a0ea3a5de.png)