Posted By


jovidic on 12/01/11

Tagged


Statistics


Viewed 460 times
Favorited by 0 user(s)

red_pokazivac.h


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

SP zadatak3


Copy this code and paste it in your HTML
  1. struct ordinacija{
  2. int x, y;
  3. ordinacija *next;
  4. };
  5. struct ordinacijaP{ // pokazivaci
  6. ordinacija *front,*rear;
  7. };
  8. typedef ordinacijaP red;
  9. typedef ordinacija pomocna;
  10.  
  11. red *InitQ(red *&Q){
  12. Q=new red;
  13. pomocna *novi=new pomocna;
  14. Q->front=novi;
  15. Q->rear=novi;
  16. novi->next=NULL;
  17. return Q;
  18. };
  19.  
  20. pomocna FrontQ(red *Q){
  21. pomocna pom;
  22. pom.x=pom.y=-1;
  23. if(Q->rear != Q->front){ // ako nije prazan red
  24. pom.x=Q->front->next->x;
  25. pom.y=Q->front->next->y;
  26. }
  27. return pom; // prazan red
  28. };
  29.  
  30. void EnQueueQ(pomocna x, red *Q){
  31. pomocna *novi=new pomocna;
  32. novi->x=x.x;
  33. novi->y=x.y;
  34. novi->next=NULL;
  35. Q->rear->next=novi;
  36. Q->rear=novi;
  37. };
  38.  
  39. void DeQueueQ(red *Q){
  40. if(Q->rear != Q->front){ // ako nije prazan red
  41. pomocna *pom=Q->front;
  42. Q->front=Q->front->next;
  43. delete pom;
  44. }
  45. else std::cout<<"Prazan red!\n";
  46. };
  47.  
  48. bool IsEmptyQ(red *Q){
  49. if(Q->rear != Q->front) // ako nije prazan red
  50. return false;
  51. return true;
  52. };

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.