当前位置: 首页 > news >正文

财务公司网站建设wordpress博客站搭建

财务公司网站建设,wordpress博客站搭建,wordpress设置图片切换时间,网页设计素材有两种分别是什么文章目录1. 设计一个单链表2. 双向链表1. 设计一个单链表 在链表类中实现这些功能#xff1a; get(index)#xff1a;获取链表中第 index 个节点的值。如果索引无效#xff0c;则返回-1。 addAtHead(val)#xff1a;在链表的第一个元素之前添加一个值为 val 的节点。插入… 文章目录1. 设计一个单链表2. 双向链表1. 设计一个单链表 在链表类中实现这些功能 get(index)获取链表中第 index 个节点的值。如果索引无效则返回-1。 addAtHead(val)在链表的第一个元素之前添加一个值为 val 的节点。插入后新节点将成为链表的第一个节点。 addAtTail(val)将值为 val 的节点追加到链表的最后一个元素。 addAtIndex(index,val)在链表中的第 index 个节点之前添加值为 val 的节点。如果 index 等于链表的长度则该节点将附加到链表的末尾。如果 index 大于链表长度则不会插入节点。如果index小于0则在头部插入节点。 deleteAtIndex(index)如果索引 index 有效则删除链表中的第 index 个节点。 来源力扣LeetCode 链接https://leetcode-cn.com/problems/design-linked-list 著作权归领扣网络所有。商业转载请联系官方授权非商业转载请注明出处。 class node { public:int val;node *next;node(int v):val(v),next(NULL) {} }; class MyLinkedList {node *head, *tail;int len; public:/** Initialize your data structure here. */MyLinkedList() {head tail NULL;len 0;}/** Get the value of the index-th node in the linked list. If the index is invalid, return -1. */int get(int index) {if(index len || index 0)return -1;node *cur head;while(index--)cur cur-next;return cur-val;}/** Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list. */void addAtHead(int val) { node *h new node(val);h-next head;head h;if(len 0)tail head;len;}/** Append a node of value val to the last element of the linked list. */void addAtTail(int val) {node *t new node(val);if(len 0){head tail t;}else{tail-next t;tail t;}len; }/** Add a node of value val before the index-th node in the linked list. If index equals to the length of linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted. */void addAtIndex(int index, int val) {if(index len)addAtTail(val);else if(index 0)addAtHead(val);else if(index len)return;else{node *cur head;while(--index)cur cur-next;node *newNode new node(val);newNode-next cur-next;cur-next newNode;len;}}/** Delete the index-th node in the linked list, if the index is valid. */void deleteAtIndex(int index) {if(index len || index 0)return;--len;node *virtualheadNode, *del, *cur;virtualheadNode new node(0);virtualheadNode-next head;cur virtualheadNode;while(index--){cur cur-next;}del cur-next;cur-next cur-next-next;delete del;head virtualheadNode-next;if(cur-next NULL)tail cur;delete virtualheadNode;} };2. 双向链表 class node { public:int val;node *next;node *prev;node(int v):val(v),next(NULL),prev(NULL) {} }; class MyLinkedList {node *head, *tail;int len; public:/** Initialize your data structure here. */MyLinkedList() {head tail NULL;len 0;}/** Get the value of the index-th node in the linked list. If the index is invalid, return -1. */int get(int index) {if(index len || index 0)return -1;node *cur head;while(index--)cur cur-next;return cur-val;}/** Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list. */void addAtHead(int val) { node *h new node(val);h-next head;head h;if(len 0)tail head;len;}/** Append a node of value val to the last element of the linked list. */void addAtTail(int val) {node *t new node(val);if(len 0){head tail t;}else{tail-next t;t-prev tail;tail t;}len; }/** Add a node of value val before the index-th node in the linked list. If index equals to the length of linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted. */void addAtIndex(int index, int val) {if(index len)addAtTail(val);else if(index 0)addAtHead(val);else if(index len)return;else{node *cur head;while(--index)cur cur-next;node *newNode new node(val);newNode-next cur-next;newNode-prev cur;cur-next-prev newNode;cur-next newNode;len;}}/** Delete the index-th node in the linked list, if the index is valid. */void deleteAtIndex(int index) {if(index len || index 0)return;--len;node *virtualheadNode, *del, *cur;virtualheadNode new node(0);virtualheadNode-next head;head-prev virtualheadNode;cur virtualheadNode;while(index--){cur cur-next;}del cur-next;cur-next cur-next-next;if(del-next) del-next-prev cur;delete del;head virtualheadNode-next;if(cur-next NULL)tail cur;delete virtualheadNode;} };
http://www.huolong8.cn/news/158069/

相关文章:

  • 闸北区网站建设网页我要建立一个网站
  • 中国城乡和住房建设部网站设计logo网站哪个好
  • 网站建设文字教程亦庄做网站
  • 太原制作响应式网站抚顺市建设银行网站
  • 网站建设开发公司推荐指数360浏览器屏蔽某网站怎么做
  • 做网站网页需要学些什么网页设计的基本原则有哪些
  • 可以做哪些网站有哪些内容学网站ui设计
  • 第一代网站建设技术wordpress amp
  • 最好的网站代运营公司小程序制作用华网天下推荐
  • 重庆电商网站建设费用东莞做网站哪家最好
  • 什么网站可以做饼图建设个网站
  • 为什么公司网站打开很慢wordpress排版乱 了
  • 北京做网站报价新手织梦网建设网站
  • 免费画图网站宿城区住房和城乡建设局网站
  • 网站软文代写建设厅官方网站企业库
  • 成都seo整站产品设计作品
  • 漯河市郾城区网站建设洛阳微信平台网站建设
  • 网站自己可以备案吗个人网站要求
  • 百度小程序对网站seo12306网站制作
  • 宛城区建网站临清网站优化
  • 阜宁做网站哪家好公司网站更换域名
  • 空间建设网站公司创建一个网站多少钱
  • 网站开发商品排序逻辑阿里巴巴运营的工作内容
  • 网站树状栏目有点昆明网站建设开发制作
  • 网站引导制作做电商一般月入多少钱
  • 自己做的网站微信pc端显示乱码电商网站有哪些使用场景
  • 网站建立分站西安seo推广
  • 勒流顺德网站建设如何设计好的网页
  • 外贸网站建设哪里实惠湖南益阳新增本土确诊0例
  • 企业网站运营推广难做吗互联网公司排名名单