Posted By

zvon123 on 11/22/10


Tagged

zadatak3


Versions (?)

Turina_Zvonimir_red_polje.h


 / Published in: C++
 

  1. struct tklijent {
  2. char ime[30];
  3. int god;
  4. int stanje;
  5. char vrsta_trans;
  6. };
  7.  
  8. struct queue {
  9. tklijent vrijednosti[10000];
  10. int front, rear;
  11. };
  12.  
  13. int AddOne(int n) {
  14. return((n+1)%10000);
  15. }
  16.  
  17. tklijent FrontQ(queue* Q) {
  18. return Q->vrijednosti[Q->front];
  19. }
  20.  
  21. void EnQueueQ (tklijent x, queue* Q) {
  22. Q->vrijednosti[Q->rear = AddOne(Q->rear)] = x;
  23. }
  24.  
  25. void DeQueueQ(queue* Q){
  26. Q->front = AddOne(Q->front);
  27. }
  28.  
  29. queue* InitQ(queue* Q){
  30. Q = new queue;
  31. Q->front = 0;
  32. Q->rear = 9999;
  33. return Q;
  34. }
  35.  
  36. bool IsEmptyQ(queue* Q){
  37. if(AddOne(Q->rear) == Q->front) return true;
  38. return false;;
  39. }

Report this snippet  

You need to login to post a comment.