Posted By


makaniski on 11/20/10

Tagged


Statistics


Viewed 45 times
Favorited by 0 user(s)

Zadatak_3_red_pokazivac_makaniski


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



Copy this code and paste it in your HTML
  1. struct tklijent{
  2. char ime[20],prez[20];
  3. int god, stanje;
  4. char vrsta;
  5. };
  6.  
  7. struct e{
  8. tklijent elem;
  9. e *slj;
  10. };
  11.  
  12. struct tred{
  13. e *p, *z;
  14. };
  15.  
  16. typedef struct tklijent element;
  17. typedef struct tred Queue;
  18.  
  19. tred *InitQ(tred *Q){
  20. e *novi = new e;
  21. Q = new tred;
  22. novi -> slj = NULL;
  23. Q -> z = novi;
  24. Q -> p = novi;
  25. return Q;
  26. };
  27.  
  28. tklijent FrontQ(tred *Q){
  29. return Q -> p -> slj -> elem;
  30. };
  31.  
  32. void EnQueueQ(element x, tred *Q){
  33. e *novi = new e;
  34. novi -> elem = x;
  35. novi -> slj = NULL;
  36. Q -> z -> slj = novi;
  37. Q -> z = novi;
  38. };
  39.  
  40. void DeQueueQ(tred *Q){
  41. e *brisi = Q -> p;
  42. Q -> p = brisi -> slj;
  43. delete brisi;
  44. };
  45.  
  46. bool IsEmptyQ(tred *Q){
  47. if(Q -> z == Q -> p)
  48. return true;
  49. else
  50. return false;
  51. };

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.