Posted By

pbilic1 on 12/03/11


Tagged


Versions (?)

pokazivac-red


 / Published in: C++
 

pokazivac-red

  1. struct trojka {
  2. int xi, yi, zi;
  3. int d;
  4. };
  5.  
  6. struct RED{
  7. trojka el;
  8. RED *next;
  9. };
  10.  
  11. struct Queue{
  12. RED *front, *rear;
  13. };
  14.  
  15.  
  16. bool IsEmptyQ(Queue *red1){
  17. if (red1->front == red1->rear)
  18. {
  19. return true;
  20. }
  21. else
  22. {
  23. return false;
  24. }
  25. }
  26.  
  27. void DeQueueQ (Queue *red1){
  28. if (!IsEmptyQ(red1)) {
  29. RED *red2 = red1->front;
  30. red1->front = (red1->front)->next;
  31. delete red2;
  32. }
  33. }
  34.  
  35. trojka FrontQ (Queue *red1){
  36. if (!IsEmptyQ(red1)) {
  37. RED *pok = (*red1).front;
  38. pok = (*pok).next;
  39. trojka vrijednost = (*pok).el;
  40. return vrijednost;
  41. }
  42. }
  43.  
  44. void InitQ (Queue *red1){
  45. RED *red2 = new RED;
  46. red2->next = 0;
  47. red1->front = red2;
  48. red1->rear = red2;
  49. }
  50.  
  51. void EnQueueQ (trojka x, Queue *red1){
  52. RED *red2 = new RED;
  53. (red1->rear)->next = red2;
  54. red2->el = x;
  55. red1->rear = red2;
  56. }

Report this snippet  

You need to login to post a comment.