Posted By


dario123 on 01/16/11

Tagged


Statistics


Viewed 44 times
Favorited by 0 user(s)

implementacija_cirkulano polje_db


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



Copy this code and paste it in your HTML
  1. struct tosoba {
  2. char imeiprezime[35];
  3. char transakcija[35];
  4. int stanje;
  5. int godiste;
  6. };
  7.  
  8. typedef tosoba elementtype;
  9.  
  10.  
  11. struct trow{
  12. elementtype elements[1000];
  13. int pocetak,kraj;
  14. };
  15.  
  16. typedef trow red;
  17.  
  18.  
  19. int AddOne(int n) {
  20. return((n+1)%10000);
  21. }
  22.  
  23.  
  24. void InitQ(red *Q){
  25. Q=new red;
  26. Q->pocetak=0;
  27. Q->kraj=9999;
  28. return Q;
  29.  
  30. }
  31.  
  32.  
  33. elementtype FrontQ(red *Q){
  34. if(IsEmptyQ(Q)==1) return 0;
  35.  
  36. else {
  37. return Q->elements[Q-pocetak];
  38. }
  39. }
  40.  
  41. void EnQueueQ(elementtype x, red *Q){
  42. if(IsEmptyQ(Q)==1) return;
  43.  
  44. else {
  45. Q->kraj=AddOne(Q->kraj);
  46. Q->elements[Q->kraj]=x;
  47. }
  48. }
  49.  
  50.  
  51. void DeQueueQ(red *Q){
  52. if(IsEmptyQ(Q)==1) return;
  53.  
  54. Q->pocetak=AddOne(Q->pocetak);
  55.  
  56. }
  57.  
  58.  
  59. bool IsEmptyQ(red *Q){
  60. if(AddOne(Q->pocetak)==Q->kraj) return 1;
  61.  
  62. else return 0;
  63. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.