Posted By


anja2pet on 11/20/10

Tagged


Statistics


Viewed 499 times
Favorited by 0 user(s)

red_pokazivac.h


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



Copy this code and paste it in your HTML
  1. struct que{
  2. elementtype value;
  3. que *next;
  4. };
  5. struct qu{
  6. que *front,*rear;
  7. };
  8.  
  9. elementtype FrontQ(qu *Q) {
  10. if (Q->front==Q->rear){
  11. cout << "\n Red je prazan ! \n";
  12. exit(0);
  13. }
  14. else
  15. return Q->front->next->value;
  16. }
  17. void EnQueueQ(elementtype x,qu *Q) {
  18. que *e=new que;
  19. e->value=x;
  20. e->next=NULL;
  21. Q->rear->next=e;
  22. Q->rear=e;
  23. }
  24. void DeQueueQ(qu *Q) {
  25. que *e;
  26. if(Q->front==Q->rear){
  27. cout << "\n Red je prazan ! \n";
  28. exit(0);
  29. }
  30. else {
  31. e=Q->front;
  32. Q->front=Q->front->next;
  33. delete e;
  34. }}
  35. void InitQ(qu *Q) {
  36. que *e=new que;
  37. Q->front=e;
  38. Q->rear=e;
  39. e->next=NULL;
  40. }
  41. int IsEmptyQ(qu *Q){
  42. if (Q->front==Q->rear)
  43. return 1;
  44. else
  45. return 0;
  46. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.