<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + PC9wPgo8cHJlIGNsYXNzPQ = "brush: java;"> # include # Include # Include Typedef struct Node {int data; char ch;} * PNODE, NODE; typedef struct QUEUE {int maxsize; int front; int rare; PNODE pBase;} * PQUEUE, QUEUE; // initialize void init (PQUEUE pQ, int length) {pQ-> maxsize = length; pQ-> pBase = (PNODE) malloc (sizeof (NODE) * length ); pQ-> front = pQ-> rare = 0; while (! PQ-> pBase) {printf ("memory allocation failed! \ N "); exit (-1);} return;} // enter the void enqueue (PQUEUE pQ, int val, char ch) {if (pQ-> rare + 1) % (pQ-> maxsize + 1) = pQ-> front) {printf ("the queue is full! % D, % c cannot join \ n ", val, ch); return;} else {pQ-> pBase [pQ-> rare % pQ-> maxsize]. data = val; pQ-> pBase [pQ-> rare % pQ-> maxsize]. ch = ch; printf ("element: % d, % c \ n", val, ch); pQ-> rare ++;} return ;} // traverse void traverse (PQUEUE pQ) {for (int I = pQ-> front; I <pQ-> rare; I ++) {printf ("% d, % c \ n ", pQ-> pBase [I % pQ-> maxsize]. data, pQ-> pBase [I % pQ-> maxsize]. ch);} return;} // void dequeue (PQUEUE pQ) {printf ("element: % d, % c \ n ", pQ-> pBase [pQ-> front], pQ-> pBase [pQ-> front]); pQ-> front ++; return;} int main (void) {QUEUE q; init (& q, 10); enqueue (& q, 0, 'z'); enqueue (& q, 1, 'y '); enqueue (& q, 2, 'x'); enqueue (& q, 3, 'w'); enqueue (& q, 4, 'V '); enqueue (& q, 5, 'U'); enqueue (& q, 6, 'T'); enqueue (& q, 7,'s '); enqueue (& q, 8, 'R'); enqueue (& q, 9, 'q'); enqueue (& q, 10, 'P '); traverse (& q); dequeue (& q); traverse (& q); enqueue (& q, 11, 'n'); traverse (& q ); dequeue (& q); traverse (& q); enqueue (& q, 12, 'M'); traverse (& q); return 0 ;}