Posted By

renata on 11/20/10


Tagged

REDpoljecpp


Versions (?)

RED_strukture_podataka


 / Published in: C++
 

  1. #include<iostream>
  2. #include<cstring>
  3. using namespace std;
  4. typedef int element;
  5. struct red{
  6. char ime_prezime[30];
  7. int g_rodenja;
  8. float stanje_racun;
  9. char transakcija[20];
  10. };
  11. struct tred{
  12. red r[1000];
  13. element front,rear;
  14. };
  15.  
  16. typedef struct red queue;
  17. tred t;
  18.  
  19. int AddOne(int n){
  20. return((n+1)%1000);
  21. }
  22.  
  23. queue* FrontQ(tred *tr){
  24. return (tr->r) ;
  25. }
  26. void EnQueueQ(char ip[],int g,int sr,char tr[],tred *ta){
  27. ta->rear=AddOne(ta->rear);
  28. strcpy(ta->r[ta->front].ime_prezime,ip);
  29. ta->r[ta->front].g_rodenja=g;
  30. ta->r[ta->front].stanje_racun=sr;
  31. strcpy(ta->r[ta->front].transakcija,tr);
  32. }
  33.  
  34. int DeQueueQ(tred *ta){
  35. if(AddOne(ta->rear)==ta->front)cout << "Red je prazan" << endl;
  36. else{ta->front=AddOne(ta->front);}
  37. }
  38.  
  39. bool IsEmptyQ(tred *ta){
  40. if(AddOne(ta->rear)==(ta->front))return true;
  41. else return false;
  42. }
  43.  
  44. int InitQ(tred *ta){
  45. (ta->front)=0;
  46. (ta->rear)=999;
  47. }

Report this snippet  

You need to login to post a comment.