Posted By

mesec on 11/22/10


Tagged

header red polje


Versions (?)

polje_red.h


 / Published in: C++
 

URL: polje_red

header polje

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct klijent{
  5. char ime[35];
  6. int god;
  7. float stanje;
  8. int transakcija;
  9. };
  10.  
  11. struct queue{
  12. klijent k[100];
  13. int front, rear;
  14. };
  15.  
  16. typedef struct queue *qu;
  17.  
  18. int AddOne (int n){
  19. return ((n+1) % 100);
  20. }
  21.  
  22. void InitQ (queue *q){
  23. q -> front = 0;
  24. q -> rear = 99;
  25. }
  26.  
  27. bool IsEmptyQ (queue *q){
  28. if (AddOne(q -> rear) == q -> front) return true;
  29. else return false;
  30. }
  31.  
  32. klijent FrontQ (queue *q){
  33. if (!IsEmptyQ(q)) return (q -> k[q -> front]);
  34. else cout << "Red je prazan." << endl;
  35. }
  36.  
  37. void EnQueueQ (klijent k, queue *q){
  38. if (AddOne(AddOne(q -> rear)) == q -> front) cout << "Red je pun." << endl;
  39. else{
  40. q -> rear = AddOne(q -> rear);
  41. q -> k[q -> rear] = k;
  42. }
  43. }
  44.  
  45. void DeQueueQ (queue *q){
  46. if (IsEmptyQ(q)) cout << "Red je prazan." << endl;
  47. else q -> front = AddOne(q -> front);
  48. }

Report this snippet  

You need to login to post a comment.