/ Published in: C++
URL: http://snipplr.com/
implementacija reda pomocu polja
Expand |
Embed | Plain Text
#include <iostream> using namespace std; struct pacijent { int x,y; short pac_prioritet; }; typedef int element; int n=9999; struct qu { pacijent elements[10000]; element front,rear; }; typedef struct qu red; int AddOne(int n) { return((n+1)%10000); } bool IsEmptyQ(red *Q) { if(AddOne(Q->rear)==Q->front) return true; else return false; } pacijent FrontQ(red *Q) { if (!IsEmptyQ(Q)) return Q->elements[Q->front]; } void DeQueueQ(red *Q) { if (!IsEmptyQ(Q)) Q->front=AddOne(Q->front); } void EnQueueQ (pacijent x, red *Q) { Q->rear=AddOne(Q->rear); Q->elements[Q->rear]=x; } void InitQ(red *Q) { Q->front=0; Q->rear=n; }
You need to login to post a comment.
