/ Published in: C++
Implementacija reda preko pokazivaÄa
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
struct pacijent { int Xi, Yi, prioritet; }; struct qu { pacijent elem; qu *sljedeci; }; struct queue { qu *front, *rear; }; queue red; void InitQ (queue &red) { qu *novi = new qu; novi->sljedeci = NULL; red.rear = novi; red.front = novi; } void EnQueueQ (pacijent x, queue &red) { qu *novi = new qu; novi->elem = x; novi->sljedeci = NULL; (red.rear)->sljedeci = novi; red.rear = novi; } pacijent FrontQ (queue red) { return ((red.front)->sljedeci)->elem; } void DeQueueQ (queue &red) { qu *del = red.front; red.front = (red.front)->sljedeci; delete del; } bool IsEmptyQ (queue red) { if (red.rear==red.front) return true; return false; }