第31851题 单选题
在非空双向链表中,若要在指针p所指结点的后方插入指针q所指的新结点,以下操作序列正确的是?

已知双向链表结点定义为:typedef struct DNode { int data; struct DNode *prior, *next; } DNode;,p指向链表中已存在的任意结点,q指向待插入的新结点,要求将q插入到p的后方。

A

q->prior = p; p->next = q; q->next = p->next; if(p->next != NULL) p->next->prior = q;

B

q->next = p->next; p->next->prior = q; q->prior = p; p->next = q;

C

q->prior = p; q->next = p->next; if(p->next != NULL) p->next->prior = q; p->next = q;

D

p->next = q; q->prior = p; q->next = p->next; p->next->prior = q;

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析