c++ 链表节点有两种类型.怎么实现
答案:1 悬赏:60
解决时间 2021-01-11 22:28
- 提问者网友:孤山下
- 2021-01-11 11:46
c++ 链表节点有两种类型.怎么实现
最佳答案
- 二级知识专家网友:话散在刀尖上
- 2021-01-11 13:11
1)结点交换时机上可以看成是节点里的值交换;
2)直接把节点的地址next的指向改变。
例如:交换LnodeA和LnodeB
用while找到节点的前一个节点pA->next = LnodeA,pB->next = LndoeB
然后pTemp = LnodeA->next;
pB->next = LnodeA;
LndoeA ->next = LnoedeB->next;
pA->next = LndoeA;
LnodeA->next = pTemp;
2)直接把节点的地址next的指向改变。
例如:交换LnodeA和LnodeB
用while找到节点的前一个节点pA->next = LnodeA,pB->next = LndoeB
然后pTemp = LnodeA->next;
pB->next = LnodeA;
LndoeA ->next = LnoedeB->next;
pA->next = LndoeA;
LnodeA->next = pTemp;
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯