数据结构作业day6

1.双向链表逆置

//逆置
doublelink rev_doublelink(doublelink head)
{
    if( NULL == head || head->next == NULL)
    {
        return head;
    }
    doublelink p = head->next;
    int len = len_doublelink(head);
    head->next = NULL;
    for(int i = 0;i < len - 1;i++)
    {
        doublelink t = p;
        p = p->next;
        t->prev = NULL;
        t->next = head;
        head->prev = t;
        head = t;
    }
    return head;
}

 

数据结构作业day6_第1张图片

你可能感兴趣的:(数据结构)