Posted By

datomala on 11/21/10


Tagged


Versions (?)

red_polje.h


 / Published in: C++
 

  1. #include<iostream>
  2. using namespace std;
  3.  
  4. struct tklijent {
  5. char prez_ime[20];
  6. int godiste;
  7. float stanje;
  8. char transakcija[15];
  9. }klijent;
  10.  
  11. struct tred {
  12. tklijent polje[15];
  13. int front, rear;
  14. }red;
  15.  
  16. int AddOne(int n) {
  17. return ((n+1)%15);
  18. }
  19.  
  20. void InitQ(tred *red) {
  21. red->front=0;
  22. red->rear=14;
  23. }
  24.  
  25. bool IsEmptyQ(tred *red) {
  26. if(AddOne(red->rear)==red->front)
  27. return true;
  28. else
  29. return false ;
  30. }
  31.  
  32. tklijent FrontQ(tred *red) {
  33. return red->polje[red->front];
  34. }
  35.  
  36. void EnQueueQ(tklijent x, tred *red) {
  37. red->rear=AddOne(red->rear);
  38. red->polje[red->rear]=x;
  39. }
  40.  
  41. void DeQueueQ(tred *red) {
  42. red->front=AddOne(red->front);
  43. }

Report this snippet  

You need to login to post a comment.