Implementation of the queue chain Storage Structure 3-end encoding, queue chain

Source: Internet
Author: User

Implementation of the queue chain Storage Structure 3-end encoding, queue chain

// Filename: list_queue.c // Authot: LupingChen/Data: 2014.06.01 // Content: main \ clear # include <stdio. h> # include <stdlib. h> // define the Node data type typedef struct Node {int data; // The Node data struct Node * next; // record the next Node address} Node; // define the Queue data type typedef struct {Node * head; // header pointer} // clear all elements of the Queue void clear (Queue * pq); int main (void) {push (& queue, 11); travel (& queue); push (& queue, 22); travel (& queue); push (& queue, 33 ); travel (& queu E); printf ("% s \ n", empty (& queue )? "Queue is blank": "queue is not available"); printf ("% s \ n", full (& queue )? "The queue is full": "The queue is not full"); printf ("----------------------------------- \ n"); travel (& queue); printf ("the queue element is % d \ n ", pop (& queue); printf ("the first element is % d \ n", get_head (& queue); printf ("the last element is: % d \ n ", get_tail (& queue); printf (" Number of queue elements: % d \ n ", size (& queue); clear (& queue ); return 0;} // clear all elements of the Queue void clear (Queue * pq) {while (pq-> head! = NULL) {Node * p = pq-> head; pq-> head = p-> next; free (p); p = NULL ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.