w******g 发帖数: 189 | 2 贴一个以作参考:
DLNode * flatten_list(DLNode *head)
{
DLNode *p, *phead, *ptail;
p = head;
while(p->next){
p = p->next;
}
phead = head;
ptail = p;
while(phead->next != NULL){
if(phead->child != NULL){
ptail->next = phead->child;
phead->child->prev = ptail;
while(ptail->next != NULL){
ptail = ptail->next;
}
}
phead = phead->next;
}
return head;
} |
|