Posted By


giga_games on 12/03/11

Tagged


Statistics


Viewed 511 times
Favorited by 0 user(s)

red_pokazivac.h


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

implementacije reda pomoću pokazivača


Copy this code and paste it in your HTML
  1. struct pacijent {
  2. int prioritet;
  3. int x, x, y;
  4. };
  5.  
  6. struct tred{
  7. pacijent pac;
  8. tred *next;
  9. };
  10.  
  11. struct que {
  12. tred *front;
  13. tred *rear;
  14. };
  15.  
  16. que red;
  17.  
  18. pacijent FrontQ (que red_atp) {
  19. return red_atp.front->next->pac;
  20. }
  21.  
  22. void EnQueueQ (pacijent pac, que &red_atp) {
  23. tred *novi;
  24. novi = new tred;
  25. novi->pac = pac;
  26. novi->next=NULL;
  27.  
  28. red_atp.rear->next=novi;
  29. red_atp.rear=novi;
  30. }
  31.  
  32. void DeQueueQ (que &red_atp) {
  33. tred *brisi;
  34. brisi = red_atp.front;
  35. red_atp.front = red_atp.front->next;
  36. delete brisi;
  37. }
  38.  
  39. bool IsEmptyQ (que red_atp) {
  40. if (red_atp.rear==red_atp.front) {
  41. return true;
  42. }
  43. else {
  44. return false;
  45. }
  46. }
  47.  
  48. void InitQ (que &red_atp) {
  49. tred *novi;
  50. novi = new tred;
  51.  
  52. novi->next=NULL;
  53. red.rear=novi;
  54. red.front=novi;
  55. }

URL: http://snipplr.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.