Posted By

makaniski on 11/20/10


Tagged

redpolje


Versions (?)

Zadatak_3_red_polje_makaniski


 / Published in: C++
 

  1. struct tklijent{
  2. char ime[20],prez[20];
  3. int god, stanje;
  4. char vrsta;
  5. };
  6.  
  7. struct tred{
  8. tklijent elem[1000];
  9. int p,z;
  10. };
  11.  
  12. typedef struct tred Queue;
  13. typedef struct tklijent element;
  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. element FrontQ(tred *Q){
  27. return Q -> elem[Q -> p];
  28. };
  29.  
  30. void EnQueueQ(element x,tred *Q){
  31. Q -> z = AddOne(Q -> z);
  32. Q -> elem[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.