Posted By


maserdare on 11/22/10

Tagged


Statistics


Viewed 408 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];
  6. char transakcija[50];
  7. int god;
  8. double stanje;
  9. };
  10.  
  11. struct tred{
  12. klijent klijenti;
  13. tred *sljedeci;
  14. tred *rear;
  15. };
  16.  
  17. typedef struct tred *red;
  18.  
  19. tred *Q = new tred;
  20. tred *Pom = new tred;
  21.  
  22. bool IsEmptyQ(tred *Qu){
  23. return Qu->sljedeci==NULL;
  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 element, tred *Qu){
  35. tred *novi = new tred, *zadnji = Qu->rear;
  36. novi -> klijenti = element;
  37. novi -> sljedeci = NULL;
  38. if(IsEmptyQ(Qu))
  39. Qu->sljedeci = novi;
  40. else
  41. zadnji->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.