在循环双链表的p所指节点之后插入s所直接点操作A,p->next=s;s->prior=p;p->next->prior=s;s->next=p->next;B.p->next=s;p->next->prior=s;s->prior=p;s->next=p->next;C.s->prior=p;s->next=p->next;p->next=s;p->next->prior=s;D.s->prior=p;s->n
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/22 15:05:44
在循环双链表的p所指节点之后插入s所直接点操作A,p->next=s;s->prior=p;p->next->prior=s;s->next=p->next;B.p->next=s;p->next->prior=s;s->prior=p;s->next=p->next;C.s->prior=p;s->next=p->next;p->next=s;p->next->prior=s;D.s->prior=p;s->n
在循环双链表的p所指节点之后插入s所直接点操作
A,p->next=s;
s->prior=p;
p->next->prior=s;
s->next=p->next;
B.p->next=s;
p->next->prior=s;
s->prior=p;
s->next=p->next;
C.s->prior=p;
s->next=p->next;
p->next=s;
p->next->prior=s;
D.s->prior=p;
s->next=p->next;
p->next->prior=s;
p->next=s;
有啥区别么,为啥我觉得就是一样呢?说得好有加分
在循环双链表的p所指节点之后插入s所直接点操作A,p->next=s;s->prior=p;p->next->prior=s;s->next=p->next;B.p->next=s;p->next->prior=s;s->prior=p;s->next=p->next;C.s->prior=p;s->next=p->next;p->next=s;p->next->prior=s;D.s->prior=p;s->n
正确答案是D
A:
p->next=s;
s->prior=p;
p->next->prior=s; //前面执行了p->next=s;这句,那么p->next->prior=s等价于s->prior=s,显然是错误的
s->next=p->next;
B:
p->next=s;
p->next->prior=s; //和A的错误相同
s->prior=p;
s->next=p->next;
C:
s->prior=p;
s->next=p->next;
p->next=s;
p->next->prior=s; //执行了上一句p->next=s之后,p->next->prior=s等价于s->prior=s,显然错误
只有D的答案是正确的