Posted By

marogina1 on 12/03/11


Tagged

red c++ ATP


Versions (?)

red_polje.h


 / Published in: C++
 

red_polje.h

  1. struct pacijent {
  2. int prior, x, y;
  3. };
  4. struct qu {
  5. pacijent el[10000];
  6. int front, rear;
  7. };
  8. qu red;
  9.  
  10. int AddOne (int mjesto) {
  11. return ((mjesto+1)%10000);
  12. }
  13. pacijent FrontQ (qu red_atp) {
  14. return red_atp.el[red_atp.front];
  15. }
  16. void EnQueueQ (pacijent pac, qu &red_atp) {
  17. red_atp.rear=AddOne(red_atp.rear);
  18. red_atp.el[red_atp.rear]=pac;
  19. }
  20. void DeQueueQ (qu &red_atp) {
  21. red_atp.front=AddOne(red_atp.front);
  22. }
  23. bool IsEmptyQ (qu red_atp) {
  24. if (AddOne(red_atp.rear)==red_atp.front) return true;
  25. return false;
  26. }
  27. void InitQ (qu &red_atp) {
  28. red_atp.front=0;
  29. red_atp.rear=9999;
  30. }

Report this snippet  

You need to login to post a comment.