Posted By

anovoselnik on 12/03/11


Tagged

strukturepodataka


Versions (?)

red_pokazivac.h


 / Published in: C++
 

Implementacija pomocu pokazivaca

  1. struct osoba {
  2. int a, x, y;
  3. };
  4. struct qu {
  5. osoba el;
  6. qu *next;
  7. };
  8. struct que {
  9. qu *front, *rear;
  10. };
  11. que red;
  12.  
  13. osoba FrontQ (que red) {
  14. return ((red.front)->next)->el;;
  15. }
  16. void EnQueueQ (osoba x, que &red) {
  17. qu *novi=new qu;
  18. novi->el=x;
  19. novi->next=NULL;
  20. (red.rear)->next=novi;
  21. red.rear=novi;
  22. }
  23. void DeQueueQ (que &red) {
  24. qu *brisi=red.front;
  25. red.front=(red.front)->next;
  26. delete brisi;
  27. }
  28. bool IsEmptyQ (que red) {
  29. if (red.rear==red.front) return true;
  30. return false;
  31. }
  32. void InitQ (que &red) {
  33. qu *novi=new qu;
  34. novi->next=NULL;
  35. red.rear=novi;
  36. red.front=novi;
  37. }

Report this snippet  

You need to login to post a comment.