Posted By

lerupcic on 11/22/10


Tagged


Versions (?)

red_polje


 / Published in: C++
 

  1. #include <string>
  2. using namespace std;
  3.  
  4. struct klijent {
  5. string ime;
  6. string prezime;
  7. int rodjen;
  8. int stanje;
  9.  
  10.  
  11. int transakcija;
  12. };
  13.  
  14.  
  15. struct qu {
  16. klijent klijenti[10000];
  17. int front;
  18. int rear;
  19. };
  20.  
  21.  
  22. typedef qu queue;
  23.  
  24. void InitQ(queue *Q) {
  25. Q->front = 0;
  26. Q->rear = 9999;
  27. }
  28.  
  29. int AddOne(int asd) {
  30. return (asd +1) % 10000;
  31. }
  32.  
  33. bool IsEmptyQ(queue *Q) {
  34. return AddOne(Q->rear) == Q->front;
  35. }
  36.  
  37. klijent FrontQ(queue *Q) {
  38. return Q->klijenti[Q->front];
  39. }
  40.  
  41.  
  42. void DeQueueQ(queue *Q) {
  43. Q->front = AddOne(Q->front);
  44. }
  45.  
  46. void EnQueueQ(queue *Q, klijent x) {
  47. Q->rear = AddOne(Q->rear);
  48. Q->klijenti[Q->rear] = x;
  49. }

Report this snippet  

You need to login to post a comment.