?? 習題-25.c
字號:
//本程序只給出了算法思想
//讀者可以自己完善本程序
void OEReform(DuLinkedList &L)
//按1,3,5,...4,2的順序重排雙向循環鏈表L中的所有結點
{
p=L.next;
while(p->next!=L&&p->next->next!=L)
{
p->next=p->next->next;
p=p->next;
} //此時p指向最后一個奇數結點
if(p->next==L)
p->next=L->pre->pre;
else
p->next=l->pre;
p=p->next; //此時p指向最后一個偶數結點
while(p->pre->pre!=L)
{
p->next=p->pre->pre;
p=p->next;
}
p->next=L; //按題目要求調整了next鏈的結構,此時pre鏈仍為原狀
for(p=L;p->next!=L;p=p->next)
p->next->pre=p;
L->pre=p; //調整pre鏈的結構
}//OEReform
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -