拆分單迴圈鍊錶

2021-08-13 21:21:13 字數 415 閱讀 9482

設單迴圈鍊錶l1,對其遍歷的結果是x1,x2,……xn。將該迴圈鍊錶拆分成兩個單迴圈鍊錶l1和l2,使得l1中含有原l1表中序號為奇數的節點,l2中含有原l1表中序號為偶數的節點;

#include #includeusing namespace std;

template struct node

;template //尾插建立迴圈單鏈表

node* creat_back( node* first,int len)

r->next=first;

return first;

}template //輸出鍊錶迴圈單鏈表

void show(node* first)

coutelse

}}int main()

單迴圈鍊錶

頭插 尾插 顯示 頭刪 尾刪 按值插入 按位置插入 查詢 長度 逆序 清除 摧毀 初始化 排序 按位置刪除 按值刪除 可以進一步優化 ifndef sclist h define sclist h include typedef int elementtype typedef enum bool 鍊...

單迴圈鍊錶

乙個遊戲,數到第n人出列 include include include struct people struct people creat struct people head,int n else p struct people malloc sizeof struct people tail ...

單迴圈鍊錶 合併

include include define len sizeof struct node typedef int datatype typedef struct node linklist 用尾指標表示帶頭結點的單迴圈鍊錶的建立 linklist hcirl creat rear next hea...