ACM模板列表 https://blog.csdn.net/nameofcsdn/article/details/107235360
双向循环链表:
class Node { public: int val; Node* left; Node* right; Node() {} Node(int _val) { val = _val; left = NULL; right = NULL; } Node(int _val, Node* _left, Node* _right) { val = _val; left = _left; right = _right; } };
//创建单节点双向循环链表
//合并双向循环链表
//创建单节点双向循环链表 void getList(Node* p) { p->left=p,p->right=p; } //合并双向循环链表 void merge2list(Node* p1,Node* p2) { p1->left->right=p2,p2->left->right=p1; Node* tmp=p2->left; p2->left = p1->left; p1->left = tmp; }