Posted By


Wrajzen on 11/20/10

Tagged


Statistics


Viewed 410 times
Favorited by 0 user(s)

red_pokazivaci.h


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  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;
  12. tred *sljedeci;
  13. tred *rear;
  14. };
  15.  
  16. typedef struct tred *red;
  17.  
  18. tred *Q = new tred;
  19. tred *P = new tred;
  20.  
  21. bool IsEmptyQ(tred *Qu){
  22. if(Qu->sljedeci == NULL) return 1;
  23. else return 0;
  24. }
  25.  
  26. klijent FrontQ(tred *Qu){
  27. if(IsEmptyQ(Qu)) cout << endl << "Red je prazan! " << endl;
  28. else{
  29. tred *front = Qu->sljedeci;
  30. return front->klijenti;
  31. }
  32. }
  33.  
  34. void EnQueueQ(klijent x, tred *Qu){
  35. tred *novi = new tred, *zajnji = Qu->rear;
  36. novi -> klijenti = x;
  37. novi -> sljedeci = NULL;
  38. if(IsEmptyQ(Qu))
  39. Qu->sljedeci = novi;
  40. else
  41. zajnji->sljedeci = novi;
  42. Qu->rear = novi;
  43. }
  44.  
  45. void DeQueueQ(tred *Qu){
  46. if(IsEmptyQ(Qu)) cout << endl << "Red je prazan! " << endl;
  47. else{
  48. tred *sljedeci = Qu->sljedeci, *front = sljedeci->sljedeci;
  49. delete sljedeci;
  50. Qu->sljedeci = front;
  51. }
  52. }
  53.  
  54. void InitQ(tred *Qu){
  55. Qu->sljedeci = NULL;
  56. Qu->rear = NULL;
  57. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.