Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int MAX_SIZE = 100;
- struct covek
- {
- string ime;
- int embr;
- bool rezultat;
- bool testiranjeSer;
- bool testiranjePCR;
- };
- struct Queue {
- covek a[MAX_SIZE];
- int S, E;
- void init() {
- S = 0;
- E = -1;
- }
- bool isFull() {
- if(E == MAX_SIZE - 1) {
- return true;
- }
- else {
- return false;
- }
- }
- bool isEmpty() {
- if(E == -1) {
- return true;
- }
- else {
- return false;
- }
- }
- void push(covek x) {
- if(isFull()) {
- cout << "queue overflow" << endl;
- exit(-1);
- }
- E++;
- a[E] = x;
- }
- covek front() {
- if(isEmpty()) {
- cout << "prazen red" << endl;
- exit(-1);
- }
- return a[S];
- }
- covek pop() {
- if(isEmpty()) {
- cout << "prazen red" << endl;
- exit(-1);
- }
- covek x = a[S];
- for(int i = 0; i < E; i++) {
- a[i] = a[i + 1];
- }
- E--;
- return x;
- }
- };
- void raspredeli_usluzi(Queue & lugje, Queue & za_rezultati, Queue & za_testiranjeSer, Queue & za_testiranje_PCR) {
- while(lugje.isEmpty() == false) {
- covek x = lugje.pop();
- if(x.rezultat) {
- za_rezultati.push(x);
- }
- else if(x.testiranjeSer) {
- za_testiranjeSer.push(x);
- }
- else if(x.testiranjePCR) {
- za_testiranje_PCR.push(x);
- }
- }
- cout << "Za rezultati: " << endl;
- while(za_rezultati.isEmpty() == false) {
- covek x = za_rezultati.pop();
- cout << x.embr << " " << x.ime << endl;
- if(x.testiranjeSer) {
- za_testiranjeSer.push(x);
- }
- else if(x.testiranjePCR) {
- za_testiranje_PCR.push(x);
- }
- }
- cout << "Za seroloski: " << endl;
- while(za_testiranjeSer.isEmpty() == false) {
- covek x = za_testiranjeSer.pop();
- cout << x.embr << " " << x.ime << endl;
- if(x.testiranjePCR) {
- za_testiranje_PCR.push(x);
- }
- }
- cout << "Za PCR: " << endl;
- while(za_testiranje_PCR.isEmpty() == false) {
- covek x = za_testiranje_PCR.pop();
- cout << x.embr << " " << x.ime << endl;
- }
- }
- // ovde vashiot kod
- 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;
- covek pomoshen;
- 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