Posted By

danacc on 11/21/10


Tagged

dasacer


Versions (?)

red_polje.h


 / Published in: C++
 

  1. #include<iostream>
  2. using namespace std;
  3. struct klijentiP{
  4. char ime_prez[40];
  5. int godina;
  6. int stanje;
  7. int transakcija;
  8. };
  9.  
  10. struct red{
  11. klijentiP klijenti[10000];
  12. int front,back;
  13. };
  14.  
  15. int AddOne(int n) {
  16. return((n+1)%10000);
  17. }
  18.  
  19. void InitQ(red *Q){
  20. Q->front=0;
  21. Q->back=9999;
  22. }
  23. klijentiP FrontQ(red *Q){
  24. return Q->klijenti[Q->front];
  25. }
  26. void EnQueueQ(klijentiP x,red *Q){
  27. if (AddOne(AddOne(Q->back))==Q->front)
  28. cout<<"red je pun!!";
  29. else{
  30. Q->back=AddOne(Q->back);
  31. Q->klijenti[Q->back]=x;
  32. }
  33. }
  34. void DeQueueQ(red *Q){
  35. if (AddOne(Q->back)!=Q->front){
  36. Q->front=AddOne(Q->front);
  37. }
  38. }
  39. int IsEmptyQ(red *Q){
  40. if(AddOne(Q->back)==Q->front)
  41. return 1;
  42. else
  43. return 0;
  44. }

Report this snippet  

You need to login to post a comment.