Posted By

icokrcek on 11/21/10


Tagged

pokazivac


Versions (?)

red_pokazivac.h


 / Published in: C++
 

datoteka zaglavlja

  1. using namespace std;
  2.  
  3. struct tklijent{
  4. char ime[15];
  5. char prezime[20];
  6. char transakcija[20];
  7. int god_rodenja;
  8. int stanje_rac;
  9. };
  10. typedef tklijent elementtype;
  11. struct qu {
  12. elementtype value;
  13. struct qu *next;
  14. };
  15.  
  16. struct que {
  17. struct qu *front,*rear;
  18. };
  19.  
  20. typedef struct que queue;
  21. typedef struct qu *element;
  22.  
  23. bool IsEmptyQ(queue *Q){
  24. if (Q->rear == Q->front) return true;
  25. else return false;
  26. }
  27.  
  28. elementtype FrontQ(queue *Q){
  29. if (IsEmptyQ(Q)){
  30. cout << "Red je prazan!" << endl;
  31. exit(1);
  32. }
  33. return Q->front->next->value;
  34. }
  35.  
  36. void EnqueueQ(elementtype x , queue *Q){
  37. element novi , prethodni;
  38. novi = new qu;
  39. novi->value = x;
  40. prethodni = Q->rear;
  41. prethodni->next = novi;
  42. Q->rear = novi;
  43. }
  44.  
  45. void DequeueQ(queue *Q){
  46. if (IsEmptyQ(Q)){
  47. cout << "Red je prazan!" << endl;
  48. exit(1);
  49. }
  50. element brisi;
  51. brisi = Q->front;
  52. Q->front = brisi->next;
  53. delete(brisi);
  54. }
  55.  
  56. void InitQ(queue *Q){
  57. element e;
  58. e = new qu;
  59. e->next = NULL;
  60. Q->front = Q->rear = e;

Report this snippet  

You need to login to post a comment.