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

admin2018-08-12  22

问题 下面的算法实现的是带附加头结点的单链表数据结点逆序连接,空缺处应当填入(    )。
    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/LcRi777K
0

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