In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "what are the operations of linked lists in C++ data structures". The content is simple and clear. I hope it can help you solve your doubts. Next, let the editor lead you to study and learn the article "what are the operations of linked lists in C++ data structures".
First create a node
Typedef struct node {int date; struct node* next;} * PNODE; PNODE creatnode (int date) {PNODE newnode = (PNODE) malloc (sizeof (struct node)); assert (newnode); newnode- > next = NULL; newnode- > date = date; return newnode;} then create a statistics node attribute
Struct List {struct node* pronode;// this is just a type struct node*tailnode; int size;}; / / create a unified linked list attribute list / / to count the number of (size) nodes in the linked list / / head and tail are used to count the header and footer of the linked list struct List* creatlist () {struct List* list = (struct List*) malloc (sizeof (struct List)); assert (list) List- > pronode = NULL; list- > tailnode = NULL; list- > size = 0 alternative return list;} add nodes insert nodes by inserting headers
Void insertbyhead (struct List* list,int date) {PNODE newnode = creatnode (date); if (list- > size = = 0) {list- > pronode = list- > tailnode = newnode;} else {newnode- > next = list- > pronode; list- > pronode = newnode;} list- > size++ Delete node / / header delete void deletehead (struct List* list) {PNODE next = list- > pronode- > next; free (list- > pronode); list- > pronode = next;} / / delete void deletetail (struct List* list) {PNODE pmove = list- > pronode / / define a moving pointer / / to find the footer pointer if (list- > size = = 0) {printf ("cannot be deleted"); return;} while (pmove- > next! = list- > tailnode) {pmove = pmove- > next } pmove- > next = NULL;// the next pointer in front of the tail pointer points to null free (list- > tailnode); list- > tailnode = pmove;} these are all the contents of the article "what are the operations of linked lists in C++ data structures"? thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.