Posted By


mgovedic on 12/02/11

Tagged


Statistics


Viewed 505 times
Favorited by 0 user(s)

red_pokazivaci.h


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

zadatak 3


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.