双向链表的基本操作

双向链表的基本操作_第1张图片
https://blog.csdn.net/qq_39032310/article/details/81735251

//双向循环链表的创建

typedef struct dlistnode{
   struct dlistnode* pnext;
   struct dlistnode* ppre;
   int data;
}dlistnode;

dlistnode *buydlistnode(int data)  //
{
    dlistnode* pnewnode=(dlistnode*)malloc(sizeof(dlistnode));
    if(NULL==pnewnode)
    {
        assert(0);
        return NULL;
    }
    pnewnode->pnext=NULL;
    pnewnode->ppre=NULL;
    pnewnode->data=data;
    
}

void dlistInit(dlistnode** phead)
{
     assert(phead);
     *phead=buydlistnode(0);
     (*phead)->pnext=(*phead);
     (*phead)->ppre=(*phead);
    
}

void dlistpushback(dlistnode* phead,int data)
{
    dlistnode* pnewnode=NULL;
    assert(phead);
    pnewnode=buydlistnode(node);

    pnewnode->ppre=phead->ppre;
    pnewnode->pnext=phead;
    pnewnode->ppre->pnext=pnewnode;
    phead->ppre=pnewnode;
}

void dlistpopback(dlistnode* phead)
{


}


你可能感兴趣的:(面试)