Posted By

mgovedic on 12/02/11


Tagged

Strukture podataka redpokazivaci


Versions (?)

red_pokazivaci.h


 / Published in: C++
 

zadatak 3

  1. #include<iostream>
  2. using namespace std;
  3.  
  4. struct podaci{
  5. int a,b,c,d;
  6. };
  7. struct red{
  8. podaci brojevi;
  9. red *sljedeci;
  10. };
  11. struct reda{
  12. red *front, *rear;
  13. };
  14.  
  15.  
  16. reda *InitQ(reda *Q){
  17. red *novi=new red;
  18. Q=new reda;
  19. Q->front=novi;
  20. Q->rear=novi;
  21. novi->sljedeci=NULL;
  22. return Q;
  23. }
  24.  
  25. podaci FrontQ(reda *Q){
  26. return Q->front->sljedeci->brojevi;
  27. }
  28. void EnQueueQ(podaci x, reda *Q){
  29. red *novi=new red;
  30. novi->brojevi=x;
  31. Q->rear->sljedeci=novi;
  32. novi->sljedeci=NULL;
  33. Q->rear=novi;
  34. }
  35. void DeQueueQ(reda *Q){
  36. if(Q->front != Q->rear){
  37. red *brisi=Q->front;
  38. Q->front=brisi->sljedeci;
  39. delete brisi;
  40. }
  41. else
  42. cout<<"red je prazan"<<endl;
  43. }
  44. bool IsEmptyQ(reda *Q){
  45. if(Q->front==Q->rear) return 1;
  46. else return 0;
  47. }

Report this snippet  

You need to login to post a comment.