Posted By

Wrajzen on 11/20/10


Tagged

array red polje implementacija ATP poljem


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Goldfinger


red_polje.h


 / Published in: C++
 

  1. #include<iostream>
  2. using namespace std;
  3.  
  4. struct klijent{
  5. char prez_ime[50], transakcija[50];
  6. int god;
  7. double stanje;
  8. };
  9.  
  10. struct tred{
  11. klijent klijenti[1000];
  12. int front,rear;
  13. }Q;
  14. tred P;
  15.  
  16. typedef struct tred red;
  17.  
  18. int addone(int n) {
  19. return((n+1)%1000);
  20. }
  21.  
  22. bool IsEmptyQ(tred Qu){
  23. if(addone(Qu.rear) == Qu.front) return 1;
  24. else return 0;
  25. }
  26.  
  27. klijent FrontQ(tred Qu){
  28. if(IsEmptyQ(Qu)) cout << endl << "Tred je prazan!" << endl;
  29. else
  30. return Qu.klijenti[Qu.front];
  31. }
  32.  
  33. void EnQueueQ(klijent x, tred &Qu){
  34. if(addone(addone(Qu.rear)) == Qu.front)
  35. cout << endl << "Tred je pun! "<< endl;
  36. else{
  37. Qu.rear = addone(Qu.rear);
  38. Qu.klijenti[Qu.rear] = x;
  39. }
  40. }
  41.  
  42. void DeQueueQ(tred &Qu){
  43. if(IsEmptyQ(Qu)) cout << endl << "Tred je prazan!" << endl;
  44. else
  45. Qu.front = addone(Qu.front);
  46. }
  47.  
  48. void InitQ(tred &Qu){
  49. Qu.front = 0;
  50. Qu.rear = 999;
  51. }

Report this snippet  

You need to login to post a comment.