/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
struct qu { kli vrijednosti; qu *sljedeci; }; struct que { qu *front, *rear; }; typedef struct que queue; kli FrontQ (queue *Q) { return Q->front->sljedeci->vrijednosti; } void EnQueueQ (kli x, queue *Q) { qu* novi = new qu; Q->rear->sljedeci=novi; Q->rear = novi; novi->vrijednosti = x; novi->sljedeci = NULL; } void DeQueueQ (queue *Q) { qu* tekuci = Q->front; Q->front = tekuci->sljedeci; delete tekuci; } queue* InitQ (queue *Q) { Q = new queue; qu* novi = new qu; Q->front = novi; Q->rear = novi; Q->front->sljedeci = NULL; return Q; } bool IsEmptyQ (queue *Q) { if (Q->front == Q->rear) return 1; else return 0; }