Guest User

Untitled

a guest
Jul 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. struct tclient{
  2. /* Osnovna struktura koja sadrzi podatke o pojedinom klijentu. */
  3. tClient label;
  4. char trans[20];
  5. };
  6. struct tqueue{
  7. /* */
  8. tclient Q[1000];
  9. int front, rear;
  10. };
  11.  
  12. typedef struct tqueue *queue;
  13. typedef struct tclient *client;
  14.  
  15.  
  16. queue FrontQ(queue Q){
  17. return Q->Q[Q->front] ;
  18. }
  19. void EnQueueQ(client El, queue Q){
  20. Q->rear=((Q->rear+1)%1000);
  21. strcpy(Q->Q[Q->rear]->label.name, El->label.name);
  22. Q->Q[Q->rear]->label.year = El->label.year;
  23. Q->Q[Q->rear]->label.saldo = El->label.saldo;
  24. strcpy(Q->Q[Q->rear]->label.trans, El->label.trans);
  25. }
  26.  
  27. void DeQueueQ(queue Q){
  28. if((Q->rear+1)%1000 == Q->front) return;
  29. else Q->front=((Q->front+1)%1000);
  30. }
  31.  
  32. bool IsEmptyQ(queue Q){
  33. if( ((Q->rear+1)%1000) == (Q->front)) return true;
  34. else return false;
  35. }
  36.  
  37. int InitQ(queue Q){
  38. Q->front = 0;
  39. Q->rear = 999;
  40. }
Add Comment
Please, Sign In to add comment