linklist insert(Node* L, int locate, int val) {
Node* s;
s = L->next;
//加,判断locate是否大于链表的长度
while (s->next != NULL ) {
locate--;
if (locate == 0) {
break;
}
s = s->next;
}
//当计数器从0开始时,计数器的值比要插入的位置多1
//
printf("%d %d", locate,s->val);
//p插入的位置是 头or尾or之间;
Node* p;
p = (Node*)malloc(sizeof(Node));
p->next = NULL;
p->prev = NULL;
p->val = 5;
p->prev = s->prev;
s->prev->next = p;
p->next = s;
s->prev = p;
return L;
}
03-21
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-05
3236
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-30
2338
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-17
214
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)