strukture 3 red_pokazivac.h


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



Copy this code and paste it in your HTML
  1. struct qu {
  2. kli vrijednosti;
  3. qu *sljedeci;
  4. };
  5.  
  6. struct que {
  7. qu *front, *rear;
  8. };
  9.  
  10. typedef struct que queue;
  11.  
  12.  
  13. kli FrontQ (queue *Q) {
  14. return Q->front->sljedeci->vrijednosti;
  15. }
  16.  
  17. void EnQueueQ (kli x, queue *Q) {
  18. qu* novi = new qu;
  19. Q->rear->sljedeci=novi;
  20. Q->rear = novi;
  21.  
  22. novi->vrijednosti = x;
  23. novi->sljedeci = NULL;
  24. }
  25.  
  26. void DeQueueQ (queue *Q) {
  27. qu* tekuci = Q->front;
  28. Q->front = tekuci->sljedeci;
  29. delete tekuci;
  30. }
  31.  
  32. queue* InitQ (queue *Q) {
  33. Q = new queue;
  34. qu* novi = new qu;
  35.  
  36. Q->front = novi;
  37. Q->rear = novi;
  38.  
  39. Q->front->sljedeci = NULL;
  40. return Q;
  41. }
  42.  
  43. bool IsEmptyQ (queue *Q) {
  44. if (Q->front == Q->rear) return 1;
  45. else return 0;
  46. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.