typedef struct nodelinklist;
typedef structlinkqueue;
void setnull(linkqueue *p)
/* set a empty queue, front and rear
pointer both point to a head node*/
void queue_init(linkqueue *pq)
/* check the queue is empty or not */
bool isempty(linkqueue q)
/* delete elements from the queue */
bool out_queue(linkqueue q, int *element)
linklist p = q->front;
q->front = q->front->next;
free(p);
*element = q->front->data;
return true;
}/* add element into the queue */
bool en_queue(linkqueue q, int element)
pnew->data = element;
pnew->next = null;
q->rear->next = pnew;
q->rear = pnew;
return true;
}/* show all elements in the current queue */
void show(linkqueue q)
linklist p;
p = q->front->next;
int i = 1;
dowhile(p != null);
return;
}/* thread handler function */
/*void *tfn(void *arg)}}
*//* safely scanf */
bool s_scanf(const char *format, int *ele_loc)
return true;
}
鏈式佇列的實現
include include define n 10 定義結點 typedef struct node node 定義佇列 typedef struct queue queue 判斷佇列是否為空 int empty queue queue 初始化佇列 queue init 入隊 int inque...
佇列的鏈式實現
今天最後老師問當棧的鏈式實現完成後,再實現佇列,是否會簡單?我回答,是的。我的理由很簡單,因為操作相同,其他的也應該類似,所以不會太難。至於實現之後,我的感受是怎麼樣的,我留在最後再說,順便總結一下。下面是標頭檔案 ifndef linklistqueue h define linklistqueu...
鏈式佇列的實現
include include define elementtype int typedef struct nodeqnode typedef struct queue const elementtype error 1 int errorflag 0 建立乙個佇列 queue createqueu...