/ Published in: C++

Implementacija reda pomoću polja
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
struct qu { tpacijent podaci[10000]; int front, rear; }; typedef struct qu queue; int AddOne(int n) { return((n+1)%10000); } tpacijent FrontQ(queue* Q) { tpacijent prvi; prvi = Q->podaci[Q->front]; return prvi; } void EnQueueQ (tpacijent x, queue* Q) { Q->rear=AddOne(Q->rear); Q->podaci[Q->rear] = x; } void DeQueueQ(queue* Q){ Q->front = AddOne(Q->front); } queue* InitQ(queue* Q){ Q = new queue; Q->front = 0; Q->rear = 9999; return Q; } bool IsEmptyQ(queue* Q){ if(AddOne(Q->rear) == Q->front) return true; return false; }
Comments
