Hàm xóa node cuối :void XoaNodeSauNodeQ(LIST &l, NODE *q)
{
if(q==NULL || q==l.Tail)
return;
NODE *p=q->pNext;
q->pNext=p->pNext;
if(q->pNext==l.Tail)
l.Tail = q;
delete p;
}
void XoaNodeTail(LIST &l)
{
NODE *p ;if(l.Head==l.Tail){delete l.Head;l.Head = l.Tail = NULL;return;}for(p=l.Head;p->pNext!=l.Tail;p=p->pNext);p->pNext=NULL;delete l.Tail;l.Tail = p;}
0 comments:
Post a Comment