/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
struct que{ elementtype value; que *next; }; struct qu{ que *front,*rear; }; elementtype FrontQ(qu *Q) { if (Q->front==Q->rear){ cout << "\n Red je prazan ! \n"; exit(0); } else return Q->front->next->value; } void EnQueueQ(elementtype x,qu *Q) { que *e=new que; e->value=x; e->next=NULL; Q->rear->next=e; Q->rear=e; } void DeQueueQ(qu *Q) { que *e; if(Q->front==Q->rear){ cout << "\n Red je prazan ! \n"; exit(0); } else { e=Q->front; Q->front=Q->front->next; delete e; }} void InitQ(qu *Q) { que *e=new que; Q->front=e; Q->rear=e; e->next=NULL; } int IsEmptyQ(qu *Q){ if (Q->front==Q->rear) return 1; else return 0; }