Posted By


mesec on 11/22/10

Tagged


Statistics


Viewed 83 times
Favorited by 0 user(s)

red_pokazivac.h


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

header pokazivac


Copy this code and paste it in your HTML
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct klijent{
  5. char ime[35];
  6. int god;
  7. float stanje;
  8. int transakcija;
  9. };
  10.  
  11. struct element{
  12. klijent k;
  13. element *next;
  14. };
  15.  
  16. struct queue{
  17. element *front, *rear;
  18. };
  19.  
  20. typedef struct queue *qu;
  21.  
  22. void InitQ (queue *q){
  23. element *novi = new element;
  24. q -> front = novi;
  25. novi -> next = NULL;
  26. q -> rear = novi;
  27. }
  28.  
  29. bool IsEmptyQ (queue *q){
  30. if (q -> rear == q -> front) return true;
  31. else return false;
  32. }
  33.  
  34. klijent FrontQ (queue *q){
  35. if(IsEmptyQ(q)) cout << "Red je prazan." << endl;
  36. else return (q -> front -> next -> k);
  37. }
  38.  
  39. void EnQueueQ (klijent k, queue *q){
  40. element *novi = new element;
  41. novi -> k = k;
  42. q -> rear -> next = novi;
  43. q -> rear = novi;
  44. novi -> next = NULL;
  45. }
  46.  
  47. void DeQueueQ (queue *q){
  48. if (IsEmptyQ(q)) cout << "Red je prazan." << endl;
  49. else{
  50. element *prvi = q -> front;
  51. q -> front = q -> front -> next;
  52. delete prvi;
  53. }
  54. }

URL: red_pokazivac

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.