Tag: return
//Loop Queue//cycqueue.h#define queuemax 15typedef struct {data data[queuemax]; //Queue Array int head; //team head int tail; //team tail }CycQueue; cycqueue *cycqueueinit () {cycqueue *q;if (q= (cycqueue *) malloc (sizeof (Cycqueue))) // Request to save queue memory {q->head = 0; //Set team header q->tail = 0; //set tail Return q;} elsereturn null; // return to Empty }void cycqueuefree (cycqueue *q) // release queue {if (q!=null) free (q);} Int cycqueueisempty (CYCQUEUE&NBSP;*Q) // whether the queue is empty { return (Q- >head==q->tail) ;} int cycqueueisfull (cycqueue *q) // queue is full {return ((q->tail+1)%queuemax == q->head) ;} Int cycqueuein (cycqueue *q,data data) // enqueue function {if ((q->tail+1)%queuemax = = q->head) {printf ("queue is full!\n"); RETURN&Nbsp;0;} else{q->tail = (q->tail+1)%queuemax; //to find the tail number q->data[q->tail] = data;return 1;} } DATA *CycQueueOut (cycqueue *q) // {if of the queue function (q->head == q->tail) {printf ("Queue is empty!\n"); return null; }else{q->head= (q->head+1)%queuemax;return & (Q->data[q->head]);} } int cycqueuelen (cycqueue *q) // get Queue Length { Int n; n=q->tail-q->head; if (n<0) n=QUEUEMAX + n; return n; } data *cycqueuepeek (cycqueue *q) // get data {if for 1th position in queue (q->head== Q->tail) {printf ("Queue already empty!\n"); return null;} else{return & (q->data[(q->head+1)%queuemax]);}}
Queue Learning Notes Loop queue