当前位置: 首页> 文旅> 酒店 > 如何引流与推广_合肥建站软件_时事新闻最新消息_怎么制作链接网页

如何引流与推广_合肥建站软件_时事新闻最新消息_怎么制作链接网页

时间:2025/7/10 0:08:42来源:https://blog.csdn.net/m0_74794884/article/details/144092767 浏览次数:0次
如何引流与推广_合肥建站软件_时事新闻最新消息_怎么制作链接网页

思路:

        (1)获取第n个结点的值

                明确链表结点下标从0开始,第n个结点

        (2)头部插入结点

               注意插入的顺序

        (3)尾部插入结点

        (4)第n个结点前插入结点

        (5)删除第n个结点

class MyLinkedList {struct NodeList {int val;NodeList* next;NodeList(int val):val(val), next(nullptr){}};private:int size;NodeList* dummyhead;public:MyLinkedList() {dummyhead = new NodeList(0); size = 0;}int get(int index) {if (index < 0 || index > (size - 1)) {return -1;}NodeList* current = dummyhead->next;while(index--){ current = current->next;}return current->val;}void addAtHead(int val) {NodeList* Newnode = new NodeList(val);Newnode->next = dummyhead->next;dummyhead->next = Newnode;size++;}void addAtTail(int val) {NodeList* Newnode = new NodeList(val);NodeList* current = dummyhead;while(current->next != NULL){current = current->next;}current->next = Newnode;size++;}void addAtIndex(int index, int val) {if (index > size) {return ;}NodeList* Newnode = new NodeList(val);NodeList* current = dummyhead;while(index--) {current = current->next;}Newnode->next = current->next;current->next = Newnode;size++;}void deleteAtIndex(int index) {if (index >= size || index < 0) {return ;}NodeList* current = dummyhead;while(index--) {current = current ->next;}NodeList* tmp = current->next;current->next = current->next->next;delete tmp;size--;}
};

关键字:如何引流与推广_合肥建站软件_时事新闻最新消息_怎么制作链接网页

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: