下面的算法实现的是带附加头结点的单链表数据结点逆序连接,空缺处应当填入( )。 void reverse(pointer h){ //h为附加头结点指针 pointer p,q; P=h一>next;h一>next=NULL;

admin2019-08-15  29

问题 下面的算法实现的是带附加头结点的单链表数据结点逆序连接,空缺处应当填入(    )。
  void reverse(pointer h){    //h为附加头结点指针
pointer p,q;
  P=h一>next;h一>next=NULL;
    while(P!=null){
    q=P;
    P=P一>next:
    q一>next=h一>next;
    h一>next(________);
    }
   }

选项 A、h
B、P
C、q
D、q->next

答案C

解析 h一>next=q;表示将当前结点作为头结点后的第一元素结点插入。
转载请注明原文地址:https://kaotiyun.com/show/plCi777K
0

相关试题推荐
最新回复(0)