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