/ Published in: C++
Implementacija reda pomoću polja.
Expand |
Embed | Plain Text
struct tpacijent { int Xi, Yi, P; }; struct qu { tpacijent element[10000]; int front, rear; }; qu red; int AddOne (int n) { return ((n+1)%10000); } tpacijent FrontQ (qu red) { return red.element[red.front]; } void EnQueueQ (tpacijent x, qu &red) { red.rear = AddOne(red.rear); red.element[red.rear] = x; } void DeQueueQ (qu &red) { red.front = AddOne(red.front); } void InitQ (qu &red) { red.front = 0; red.rear = 9999; } bool IsEmptyQ (qu red) { if (AddOne(red.rear) == red.front) return true; else return false; }
You need to login to post a comment.
