Posted By

pbilic1 on 12/03/11


Tagged


Versions (?)

poljr-red


 / Published in: C++
 

polje-red

  1. struct trojka {
  2. int xi, yi, zi;
  3. int d;
  4. };
  5.  
  6. struct Queue {
  7. int front, rear;
  8. trojka polje[10000];
  9. };
  10.  
  11. void DeQueueQ (Queue *red) {
  12. ((*red).front)++;
  13. (*red).front = (*red).front % 10000;
  14. }
  15.  
  16. void EnQueueQ (trojka x, Queue *red) {
  17. red->polje[((*red).rear+1) % 10000] = x;
  18. red->rear = (red->rear + 1) % 10000;
  19. }
  20.  
  21. bool IsEmptyQ (Queue *red) {
  22. if ((red->rear + 1) % 10000 == red->front) {
  23. return true;
  24. }
  25. else {
  26. return false;
  27. }
  28. }
  29.  
  30. trojka FrontQ (Queue *red) {
  31. if (!IsEmptyQ(red))
  32. return red->polje[red->front];
  33. }
  34.  
  35. void InitQ (Queue *red) {
  36. (*red).rear = 9999;
  37. (*red).front = 0;
  38. }

Report this snippet  

You need to login to post a comment.