Advertisement
Josif_tepe

Untitled

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