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 ;}}