Posted By


zstrahij1 on 12/03/11

Tagged


Statistics


Viewed 453 times
Favorited by 0 user(s)

red_pokazivac.h


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

Header pokazivaci


Copy this code and paste it in your HTML
  1. #include <cstdlib>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. struct _pacijent
  7. {
  8. int broj, cekaonica, ordinacija, prioritet;
  9. };
  10.  
  11. struct _t
  12. {
  13. _pacijent pacijent;
  14. _t *sljedeci;
  15. };
  16.  
  17. struct _red
  18. {
  19. _t *front, *rear;
  20. };
  21.  
  22. void InitQ(_red *red)
  23. {
  24. red->front=(_t*)malloc(sizeof(_t));
  25. red->front->sljedeci=NULL;
  26. red->rear=red->front;
  27. cout<<"Red inicijaliziran!"<<endl;
  28. };
  29.  
  30. bool IsEmptyQ(_red *red)
  31. {
  32. if(red->front==red->rear) return true;
  33. else return false;
  34. };
  35.  
  36. void EnQueueQ(_pacijent pacijent,_red *red)
  37. {
  38. _t *temp;
  39. temp=new _t;
  40. temp->pacijent=pacijent;
  41. temp->sljedeci=NULL;
  42. red->rear->sljedeci=c;
  43. red->rear=temp;
  44. };
  45.  
  46. void DeQueueQ(_red *red)
  47. {
  48. _t *temp;
  49. if(IsEmptyQ(red)) cout<<"Red prazan!"<<endl;
  50. else
  51. {
  52. temp=red->front;
  53. red->front=red->front->sljedeci;
  54. free(temp);
  55. }
  56. };
  57.  
  58. _pacijent FrontQ(_red *red)
  59. {
  60. if(IsEmptyQ(red)) cout<<"Red prazan!"<<endl;
  61. else return (red->front->sljedeci->pacijent);
  62. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.