Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- #define MAX 50
- struct covek
- {
- string ime;
- int embr;
- bool rezultat;
- bool testiranjeSer;
- bool testiranjePCR;
- };
- struct Queue {
- covek niza[MAX];
- int front, rear;
- void init() {
- front = 0;
- rear = -1;
- }
- bool isEmpty() {
- if(rear == -1) {
- return true;
- }
- else {
- return false;
- }
- }
- bool isFull() {
- if(rear == MAX - 1) {
- return true;
- }
- else {
- return false;
- }
- }
- void push(covek x) {
- if(isFull()) {
- cout << "Redot e poln" << endl;
- return;
- }
- rear++;
- niza[rear] = x;
- }
- covek pop() {
- if(isEmpty()) {
- cout << "Redot e prazen" << endl;
- exit(-1);
- }
- covek result = niza[front];
- for(int i = front; i < rear; i++) {
- niza[i] = niza[i + 1];
- }
- rear--;
- return result;
- }
- covek peek() {
- if(isEmpty()) {
- cout << "Redot e prazen" << endl;
- exit(-1);
- }
- return niza[front];
- }
- };
- void raspredeli_usluzi(Queue lugje, Queue za_rezultati, Queue za_testiranjeSer, Queue za_testiranje_PCR) {
- while(lugje.isEmpty() == false) {
- covek c = lugje.pop();
- if(c.rezultat == true) {
- za_rezultati.push(c);
- }
- else if(c.testiranjeSer == true) {
- za_testiranjeSer.push(c);
- }
- else if(c.testiranjePCR == true) {
- za_testiranje_PCR.push(c);
- }
- }
- cout << "Za rezultati: " << endl;
- while(za_rezultati.isEmpty() == false) {
- covek c = za_rezultati.pop();
- cout << c.ime << " " << c.embr << " e usluzhen za rezultati!" << endl;
- if(c.testiranjeSer == true) {
- za_testiranjeSer.push(c);
- }
- else if(c.testiranjePCR == true) {
- za_testiranje_PCR.push(c);
- }
- }
- cout << "Za serolosko testiranje: " << endl;
- while(za_testiranjeSer.isEmpty() == false) {
- covek c = za_testiranjeSer.pop();
- cout << c.ime << " " << c.embr << "e usluzhen za serolosko testiranje!" << endl;
- if(c.testiranjePCR == true) {
- za_testiranje_PCR.push(c);
- }
- }
- cout << "Za PCR testiranje: " << endl;
- while(za_testiranje_PCR.isEmpty() == false) {
- covek c = za_testiranje_PCR.pop();
- cout << c.ime << " " << c.embr << " e usluzhen za PCR testiranje" << endl;
- }
- }
- int main()
- {
- Queue lugje, za_testiranjeSer, za_testiranjePCR, za_rezultati;
- covek pomoshen;
- char c;
- int i=1;
- lugje.init();
- za_rezultati.init();
- za_testiranjeSer.init();
- za_testiranjePCR.init();
- while(1)
- {
- cout<<"Vnesete podatoci za covek "<<i<<endl;
- cin>>pomoshen.ime>>pomoshen.embr>>pomoshen.rezultat>>pomoshen. testiranjeSer>>pomoshen.testiranjePCR;
- lugje.push(pomoshen);
- cout<<endl;
- cout<<"Vnesete . za kraj na vnesuvanjeto"<<endl; cin>>c;
- if(c == '.') break;
- i++;
- }
- raspredeli_usluzi(lugje, za_rezultati, za_testiranjeSer, za_testiranjePCR); cout<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement