Posted By

KarloBatrla on 12/02/11


Tagged

polje


Versions (?)

polje


 / Published in: C++
 

polje

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct tred {
  5. int x, y;
  6. int i;
  7. short prioritet;
  8. };
  9.  
  10. typedef int element;
  11. int n=9999;
  12.  
  13. struct qu {
  14. tred elements[10000];
  15. element front,rear;
  16. };
  17.  
  18. typedef struct qu queue;
  19. int AddOne(int n) {
  20. return((n+1)%10000);
  21. }
  22.  
  23. bool IsEmptyQ(queue *Q) {
  24. if(AddOne(Q->rear)==Q->front) return true;
  25. else return false;
  26. }
  27.  
  28. tred FrontQ(queue *Q) {
  29. if (!IsEmptyQ(Q)) return Q->elements[Q->front];
  30. }
  31.  
  32. void DeQueueQ(queue *Q) {
  33. if (!IsEmptyQ(Q)) Q->front=AddOne(Q->front);
  34. }
  35.  
  36. void EnQueueQ (tred x, queue *Q) {
  37. Q->rear=AddOne(Q->rear);
  38. Q->elements[Q->rear]=x;
  39. }
  40. void InitQ(queue *Q) {
  41. Q->front=0;
  42. Q->rear=n;
  43. }

Report this snippet  

You need to login to post a comment.