Posted By


mjurman on 12/03/11

Tagged


Statistics


Viewed 485 times
Favorited by 0 user(s)

Red_pokazivac.h


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

implementacija reda pomocu pokazivaca


Copy this code and paste it in your HTML
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct pacijent {
  5. int x, y;
  6. short pac_prioritet;
  7. };
  8.  
  9. struct qu {
  10. pacijent value;
  11. qu *next;
  12. };
  13.  
  14. struct que {
  15. qu *front, *rear;
  16. };
  17.  
  18. typedef struct que red;
  19. typedef struct qu element;
  20. element *glava=new element;
  21.  
  22. bool IsEmptyQ(red *Q) {
  23. if (Q->rear==Q->front) return true;
  24. else return false;
  25. }
  26.  
  27. pacijent FrontQ(red *Q) {
  28. if (!IsEmptyQ(Q)) {
  29. element *pom=Q->front;
  30. pom=pom->next;
  31. return pom->value;
  32. }
  33. }
  34.  
  35. void DeQueueQ(red *Q) {
  36. if (!IsEmptyQ(Q)) {
  37. element *brisi=Q->front;
  38. Q->front=brisi->next;
  39. delete brisi;
  40. }
  41. }
  42.  
  43. void EnQueueQ (pacijent x, red *Q) {
  44. element *zadnji=Q->rear;
  45. element *novi=new element;
  46. novi->value=x;
  47. novi->next=NULL;
  48. zadnji->next=novi;
  49. Q->rear=novi;
  50. }
  51.  
  52. void InitQ (red *Q) {
  53. Q->front=glava;
  54. Q->rear=glava;
  55. }

URL: http://snipplr.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.