Posted By


dapatafta on 11/20/10

Tagged


Statistics


Viewed 335 times
Favorited by 0 user(s)

red_pokazivac.h


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



Copy this code and paste it in your HTML
  1. struct klijent
  2. {
  3. char ime[20];
  4. char prezime[20];
  5. int godina;
  6. float stanje;
  7. int transakcija;
  8. };
  9.  
  10. struct elementreda
  11. {
  12. klijent value;
  13. elementreda *next;
  14. };
  15.  
  16. struct tred
  17. {
  18. elementreda *front, *rear;
  19. };
  20.  
  21. typedef struct tred *pred;
  22.  
  23. klijent FrontQ(tred *Q)
  24. {
  25. if (Q->front == Q->rear)
  26. {
  27. klijent x;
  28. x.godina = 0;
  29. x.stanje = 0;
  30. x.transakcija = 0;
  31.  
  32. return x;
  33. }
  34. else
  35. return Q->front->next->value;
  36. }
  37.  
  38. void EnQueueQ(klijent x, tred *Q)
  39. {
  40. elementreda *e = new elementreda;
  41. e->value = x;
  42. e->next = NULL;
  43. Q->rear->next = e;
  44. Q->rear = e;
  45. }
  46.  
  47. void DeQueueQ(tred *Q)
  48. {
  49. elementreda *e;
  50.  
  51. if (Q->front != Q->rear)
  52. {
  53. e = Q->front;
  54. Q->front = Q->front->next;
  55. delete e;
  56. }
  57. }
  58.  
  59. void InitQ(tred *Q)
  60. {
  61. elementreda *e = new elementreda;
  62. Q->front = e;
  63. Q->rear = e;
  64. e->next = NULL;
  65.  
  66. }
  67.  
  68. bool IsEmptyQ(tred *Q)
  69. {
  70. if (Q->front == Q->rear)
  71. return true;
  72. else
  73. return false;
  74. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.