strukture 3 red_polje.h


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



Copy this code and paste it in your HTML
  1. struct qu {
  2. kli vrijednosti[10000];
  3. int front, rear;
  4. };
  5.  
  6. typedef struct qu queue;
  7.  
  8. int AddOne(int n) {
  9. return((n+1)%10000);
  10. }
  11.  
  12.  
  13. kli FrontQ (queue *Q) {
  14. return Q->vrijednosti[Q->front];
  15. }
  16.  
  17. void EnQueueQ (kli x, queue *Q) {
  18. Q->rear = AddOne(Q->rear);
  19. Q->vrijednosti[Q->rear] = x;
  20. }
  21.  
  22. void DeQueueQ (queue *Q){
  23. Q->front = AddOne(Q->front);
  24. }
  25.  
  26. queue* InitQ (queue *Q){
  27. Q = new queue;
  28. Q->front = 0;
  29. Q->rear = 9999;
  30. return Q;
  31. }
  32.  
  33. bool IsEmptyQ (queue *Q){
  34. if( Q->front == AddOne(Q->rear) ) return true;
  35. return false;
  36. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.