Josif_tepe

Untitled

Sep 3rd, 2025
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.23 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. const int MAX_SIZE = 100;
  4.  
  5.  
  6. struct covek
  7. {
  8. string ime;
  9. int embr;
  10. bool rezultat;
  11. bool testiranjeSer;
  12. bool testiranjePCR;
  13. };
  14. struct Queue {
  15.     covek a[MAX_SIZE];
  16.     int S, E;
  17.    
  18.     void init() {
  19.         S = 0;
  20.         E = -1;
  21.     }
  22.    
  23.     bool isFull() {
  24.         if(E == MAX_SIZE - 1) {
  25.             return true;
  26.         }
  27.         else {
  28.             return false;
  29.         }
  30.     }
  31.    
  32.     bool isEmpty() {
  33.         if(E == -1) {
  34.             return true;
  35.         }
  36.         else {
  37.             return false;
  38.         }
  39.     }
  40.    
  41.     void push(covek x) {
  42.         if(isFull()) {
  43.             cout << "queue overflow" << endl;
  44.             exit(-1);
  45.         }
  46.         E++;
  47.         a[E] = x;
  48.     }
  49.    
  50.     covek front() {
  51.         if(isEmpty()) {
  52.             cout << "prazen red" << endl;
  53.             exit(-1);
  54.         }
  55.         return a[S];
  56.     }
  57.    
  58.     covek pop() {
  59.         if(isEmpty()) {
  60.             cout << "prazen red" << endl;
  61.             exit(-1);
  62.         }
  63.        
  64.         covek x = a[S];
  65.        
  66.         for(int i = 0; i < E; i++) {
  67.             a[i] = a[i + 1];
  68.         }
  69.         E--;
  70.        
  71.         return x;
  72.     }
  73.    
  74.    
  75. };
  76. void raspredeli_usluzi(Queue & lugje, Queue & za_rezultati, Queue & za_testiranjeSer, Queue & za_testiranje_PCR) {
  77.    
  78.    
  79.     while(lugje.isEmpty() == false) {
  80.         covek x = lugje.pop();
  81.        
  82.         if(x.rezultat) {
  83.             za_rezultati.push(x);
  84.         }
  85.         else if(x.testiranjeSer) {
  86.             za_testiranjeSer.push(x);
  87.         }
  88.         else if(x.testiranjePCR) {
  89.             za_testiranje_PCR.push(x);
  90.         }
  91.     }
  92.    
  93.     cout << "Za rezultati: " << endl;
  94.    
  95.     while(za_rezultati.isEmpty() == false) {
  96.         covek x = za_rezultati.pop();
  97.         cout << x.embr << " " << x.ime << endl;
  98.        
  99.         if(x.testiranjeSer) {
  100.             za_testiranjeSer.push(x);
  101.         }
  102.         else if(x.testiranjePCR) {
  103.             za_testiranje_PCR.push(x);
  104.         }
  105.     }
  106.    
  107.     cout << "Za seroloski: " << endl;
  108.     while(za_testiranjeSer.isEmpty() == false) {
  109.         covek x = za_testiranjeSer.pop();
  110.        
  111.         cout << x.embr << " " << x.ime << endl;
  112.        
  113.         if(x.testiranjePCR) {
  114.             za_testiranje_PCR.push(x);
  115.         }
  116.     }
  117.    
  118.     cout << "Za PCR: " << endl;
  119.     while(za_testiranje_PCR.isEmpty() == false) {
  120.         covek x = za_testiranje_PCR.pop();
  121.        
  122.         cout << x.embr << " " << x.ime << endl;
  123.     }
  124. }
  125. // ovde vashiot kod
  126. int main()
  127. {
  128. Queue lugje, za_testiranjeSer, za_testiranjePCR, za_rezultati;
  129. covek pomoshen;
  130. char c;
  131. int i=1;
  132. lugje.init();
  133. za_rezultati.init();
  134. za_testiranjeSer.init();
  135. za_testiranjePCR.init();
  136. while(1)
  137. {
  138.     cout<<"Vnesete podatoci za covek "<<i<<endl;
  139.     covek pomoshen;
  140.     cin>>pomoshen.ime>>pomoshen.embr>>pomoshen.rezultat>>pomoshen.testiranjeSer>>pomoshen.testiranjePCR;
  141.     lugje.push(pomoshen);
  142.     cout<<endl;
  143.     cout<<"Vnesete . za kraj na vnesuvanjeto"<<endl;
  144.     cin>>c;
  145.     if(c == '.'){
  146.         break;
  147.     }
  148.     i++;
  149.  
  150.         }
  151.     raspredeli_usluzi(lugje, za_rezultati, za_testiranjeSer, za_testiranjePCR);
  152.  
  153.         cout<<endl;
  154.         return 0;
  155.         }
  156.  
Advertisement
Add Comment
Please, Sign In to add comment