Posted By


majstorica on 11/20/10

Tagged


Statistics


Viewed 526 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 klijent{
  2. char ime[20],prezime[20];
  3. int godina, stanje, trans;
  4. };
  5.  
  6. typedef klijent elementtype;
  7. struct qu {
  8. elementtype value;
  9. struct qu *next,*front,*rear;
  10. };
  11.  
  12.  
  13. void InitQ(qu *Q) {
  14. qu *pom;
  15. pom = new qu;
  16. (*Q).front=pom;
  17. (*Q).rear=pom;
  18. (*pom).next=NULL;
  19. }
  20.  
  21. void EnqueueQ( elementtype x,qu *Q) {
  22. qu *e;
  23. e=new qu;
  24. (*e).value=x;
  25. (*e).next=NULL;
  26. (*(*Q).rear).next=e;
  27. (*Q).rear=e;
  28. }
  29.  
  30. elementtype FrontQ(qu *Q) {
  31. if ((*Q).front==(*Q).rear) {
  32. printf("Red je prazan");
  33. exit(0);
  34. }
  35. else
  36. return((*(*(*Q).front).next).value);
  37. }
  38.  
  39. void DequeueQ(qu *Q) {
  40. qu *e;
  41. if ((*Q).front==(*Q).rear) {
  42. printf("Red je prazan");
  43. exit(0);
  44. }
  45. else {
  46. e=(*Q).front;
  47. (*Q).front=(*(*Q).front).next;
  48. free(e);
  49. }
  50. }
  51.  
  52. int IsEmptyQ(qu *Q){
  53. if ((*Q).front==(*Q).rear)
  54. return(1);
  55. else
  56. return(0);
  57. }
  58.  
  59. //Iva Kis

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.