Posted By

ledalink on 11/22/10


Tagged

sp zadatak3


Versions (?)

red_pokazivac.h


 / Published in: C++
 

  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. typedef int element;
  6.  
  7. struct red{
  8. tpodaci rbr;
  9. red *slijedeci;
  10. red *front,*rear;
  11. };
  12.  
  13.  
  14. typedef struct red *ele;
  15.  
  16. tpodaci FrontQ(red *jedan){
  17. if(jedan->rear!=jedan->front)
  18. return jedan->front->slijedeci->rbr;
  19. else{
  20. cout<<"Red je prazan!";
  21. exit(0);
  22. }
  23. }
  24.  
  25. void EnQueueQ(tpodaci x,red *jedan){
  26.  
  27. red *novi=new red;
  28. novi->rbr=x;
  29. novi->slijedeci=NULL;
  30. jedan->rear->slijedeci=novi;
  31. jedan->rear=novi;
  32.  
  33. }
  34.  
  35.  
  36. void DeQueueQ(red *jedan){
  37.  
  38. red *brisani=new red;
  39. if(jedan->rear!=jedan->front){
  40. brisani=jedan->front;
  41. jedan->front=brisani->slijedeci;
  42. delete brisani;
  43.  
  44. }else{
  45. cout<<"Red je prazan!";
  46. exit(0);
  47. }
  48.  
  49. }
  50.  
  51.  
  52. void InitQ(red *jedan){
  53.  
  54. red*novi=new red;
  55. jedan->rear=novi;
  56. jedan->front=novi;
  57. novi->slijedeci=NULL;
  58.  
  59. }
  60.  
  61.  
  62. int IsEmptyQ(red *jedan){
  63. if(jedan->front==jedan->rear)
  64. return (-1);
  65. else
  66. return 0;
  67.  
  68. }

Report this snippet  

You need to login to post a comment.