In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "the implementation method of chain storage queue in C language". In daily operation, I believe that many people have doubts about the implementation method of chain storage queue in C language. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "the implementation method of chain storage queue in C language". Next, please follow the editor to study!
# include # include using namespace std;typedef struct node {int data; struct node * next;} NODE;typedef struct queue {NODE* head; NODE* tail;} QUEUE;QUEUE* create_queue () {QUEUE* queue = new QUEUE; queue- > head = NULL; queue- > tail = NULL; return queue;} NODE* create_node (int data) {NODE* node = new NODE; node- > data = data; node- > next = NULL; return node } void queue_push (QUEUE* queue,int data) {NODE* node = create_node (data); if (queue- > tail = = NULL) {queue- > tail = node; queue- > head = node;} else {queue- > tail- > next = node; queue- > tail = node;} NODE* destroy_node (NODE* node) {NODE* next = node- > next; delete node; return next } int queue_pop (QUEUE* queue) {if (queue- > head = = NULL) {assert (false);} int data = queue- > head- > data; queue- > head = destroy_node (queue- > head); if (queue- > head = = NULL) {queue- > tail = NULL;} return data;} int queue_size (QUEUE* queue) {int size = 0; NODE* node= NULL; for (node=queue- > head; node) Node=node- > next) {size++;} return size;} void clear (QUEUE* queue) {while (queue- > head) {queue- > head = destroy_node (queue- > head);} queue- > tail = NULL;} void destroy_queue (QUEUE* queue) {clear (queue); delete queue } bool queue_empty (QUEUE* queue) {if ((queue- > head==NULL) & & (queue- > tail==NULL)) {return true;} return false;} int main () {QUEUE* queue = create_queue (); cout
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.