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