Posted By

nincarevi on 11/21/10


Tagged


Versions (?)

3. program - red_polje.h


 / Published in: C++
 

  1. //red_polje.h
  2.  
  3. struct klijent_banke
  4. {
  5. char prezime_ime[30];
  6. int godina_rodjenja;
  7. int stanje_bankovnog_racuna;
  8. int vrsta_transakcije;
  9. };
  10. #define VELICINA 100
  11. struct ATP_Red
  12. {
  13. klijent_banke polje[VELICINA];
  14. int front;
  15. int rear;
  16. };
  17.  
  18. void EnQueueQ (klijent_banke x, ATP_Red *red)
  19. {
  20. red->polje[(red->rear+1) % VELICINA] = x;
  21. red->rear = (red->rear + 1) % VELICINA;
  22. }
  23.  
  24. void DeQueueQ (ATP_Red *red)
  25. {
  26. (*red).front = ((*red).front + 1) % VELICINA;
  27. }
  28.  
  29. bool IsEmptyQ (ATP_Red *red)
  30. {
  31. if ((red->rear + 1) % VELICINA == red->front)
  32. {
  33. return true;
  34. }
  35. else
  36. {
  37. return false;
  38. }
  39. }
  40.  
  41. void InitQ (ATP_Red *red)
  42. {
  43. red->rear = VELICINA - 1;
  44. red->front = 0;
  45. }
  46.  
  47. klijent_banke FrontQ (ATP_Red *red)
  48. {
  49. if (IsEmptyQ(red) == false)
  50. {
  51. return red->polje[red->front];
  52. }
  53. else
  54. {
  55. cout << endl << endl << "Red je prazan!" << endl << endl;
  56. }
  57. }

Report this snippet  

You need to login to post a comment.