/ Published in: C++

implementacija reda pomocu pokazivaca
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> using namespace std; struct pacijent { int x, y; short pac_prioritet; }; struct qu { pacijent value; qu *next; }; struct que { qu *front, *rear; }; typedef struct que red; typedef struct qu element; element *glava=new element; bool IsEmptyQ(red *Q) { if (Q->rear==Q->front) return true; else return false; } pacijent FrontQ(red *Q) { if (!IsEmptyQ(Q)) { element *pom=Q->front; pom=pom->next; return pom->value; } } void DeQueueQ(red *Q) { if (!IsEmptyQ(Q)) { element *brisi=Q->front; Q->front=brisi->next; delete brisi; } } void EnQueueQ (pacijent x, red *Q) { element *zadnji=Q->rear; element *novi=new element; novi->value=x; novi->next=NULL; zadnji->next=novi; Q->rear=novi; } void InitQ (red *Q) { Q->front=glava; Q->rear=glava; }
URL: http://snipplr.com
Comments
