首页 > 试题广场 >

向单链表的末尾添加一个元素的算法。

[问答题]

在程序适当位置填入缺失内容:(请将序号及内容填写在答题卡上)

向单链表的末尾添加一个元素的算法。

void  InserRear(LNode*& HL, const ElemType& item)
{
     LNde*  newptr;
     newptr=new LNode;
     if (     )
     {
         err<<”Memory allocation failare!”<<end1;
         exit(1);
     }
    (              )=item;
    newptr->next=NULL
    if (HL==NULL)
        HL=(                 );
    else {
        LNode*  p=HL;
        While (P->next!=NULL)
        (                );
        p->next=newptr;
    }
}
  1. newptr == NULL 或 newptr;
  2. newptr->data;
  3. newptr;
  4. p = p->next;
发表于 2019-11-25 13:42:11 回复(0)
发表于 2020-04-30 17:17:39 回复(0)