Posted By


davucina on 12/03/11

Tagged


Statistics


Viewed 552 times
Favorited by 0 user(s)

red_pokazivac.h


/ Published in: C++
Save to your folder(s)

Implementacija reda pomoću pokazivača.


Copy this code and paste it in your HTML
  1. struct tpacijent {
  2. int Xi, Yi, P;
  3. };
  4.  
  5. struct qu {
  6. tpacijent element;
  7. qu *sljedeci;
  8. };
  9.  
  10. struct tred {
  11. qu *front, *rear;
  12. };
  13.  
  14. tred red;
  15.  
  16. tpacijent FrontQ (tred red) {
  17. return ((red.front)->sljedeci)->element;
  18. }
  19.  
  20. void EnQueueQ (tpacijent x, tred &red) {
  21. qu *novi = new qu;
  22. novi->element = x;
  23. novi->sljedeci = NULL;
  24. (red.rear)->sljedeci = novi;
  25. red.rear = novi;
  26. }
  27.  
  28. void DeQueueQ (tred &red) {
  29. qu *pom = red.front;
  30. red.front = (red.front)->sljedeci;
  31. delete pom;
  32. }
  33.  
  34. void InitQ (tred &red) {
  35. qu *novi = new qu;
  36. novi->sljedeci = NULL;
  37. red.rear = novi;
  38. red.front = novi;
  39. }
  40.  
  41. bool IsEmptyQ (tred red) {
  42. if (red.rear==red.front) return true;
  43. else return false;
  44. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.