Posted By

alsobodic on 11/22/10


Tagged


Versions (?)

red_pokazivac.h


 / Published in: C++
 

  1. struct tklijent{
  2. char ime[50],prez[50];
  3. int god, stanje;
  4. char vrstatrans;
  5. };
  6.  
  7. struct tRed {
  8. tklijent elements[1000];
  9. int p,z;
  10. };
  11.  
  12. typedef struct tRed Queue;
  13. typedef struct tklijent el;
  14.  
  15. tRed* InitQ(tRed *Q){
  16. Q = new tRed;
  17. Q -> p = 0;
  18. Q -> z = 999;
  19. return Q;
  20. };
  21.  
  22. int AddOne(int n){
  23. return ((n+1)%1000);
  24. };
  25.  
  26. el FrontQ(tRed *Q){
  27. return Q -> elements[Q -> p];
  28. };
  29.  
  30. void EnQueueQ(el x,tRed *Q){
  31. Q -> z = AddOne(Q -> z);
  32. Q -> elements[Q -> z] = x;
  33. };
  34.  
  35. void DeQueueQ(tRed *Q){
  36. Q -> p = AddOne(Q -> p);
  37. };
  38.  
  39. bool IsEmptyQ(tRed *Q){
  40. if(AddOne(Q -> z) == Q -> p)
  41. return true;
  42. else
  43. return false;
  44. };

Report this snippet  

You need to login to post a comment.