Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #define MAX 20
- using namespace std;
- struct Covek
- {
- char ime[20];
- char prezime[20];
- bool lk,p,vd;
- };
- struct Red
- {
- Covek niza[MAX];
- int start,end;
- };
- void inicijaliziraj(Red &r)
- {
- r.start=0;
- r.end=-1;
- }
- void vmetni(Red &r,Covek &c)
- {
- if(r.end==MAX-1) cout<<"greska";
- else
- {
- r.niza[++r.end]=c;
- }
- }
- Covek izvadi(Red &r)
- {
- Covek pom;
- if(r.end==-1) cout<<" use edna greska";
- else
- {
- pom=r.niza[r.start];
- for(int i=r.start;i<r.end;i++)
- {
- r.niza[i]=r.niza[i+1];
- }
- r.end--;
- }
- return pom;
- }
- void opsluzuva(Red &r1,Red &r2,Red &r3)
- {
- Covek c;
- while(r1.end>-1)
- {
- c=izvadi(r1);
- c.lk=false; cout<<c.ime<<" "<<c.prezime<<" licna karta"<<endl;
- if(c.p==true) vmetni(r2,c);
- else if(c.vd==true) vmetni(r3,c);
- }
- while(r2.end>-1)
- {
- c=izvadi(r2);
- c.p=false; cout<<c.ime<<" "<<c.prezime<<" pasos"<<endl;
- if(c.vd==true) vmetni(r3,c);
- }
- while(r3.end>-1)
- {
- c=izvadi(r3);
- c.vd=false; cout<<c.ime<<" "<<c.prezime<<" vozacka"<<endl;
- }
- }
- int main()
- {
- Red rlk, rp, rvd;
- inicijaliziraj(rlk);
- inicijaliziraj(rp);
- inicijaliziraj(rvd);
- Covek niza[20];
- bool znak;
- for(int i=0;i<3;i++)
- {
- cout<<"Vnesete ime:"<<endl;
- cin>>niza[i].ime;
- cout<<"Vnesete prezime"<<endl;
- cin>>niza[i].prezime;
- cout<<"Dali kje chekate vo redot za lichni karti? (1=da, 0=ne)"<<endl;
- cin>>niza[i].lk;
- cout<<"Dali kje chekate vo redot za pasoshi? (1=da, 0=ne)"<<endl;
- cin>>niza[i].p;
- cout<<"Dali kje chekate vo redot za vozachki dozvoli? (1=da, 0=ne)"<<endl;
- cin>>niza[i].vd;
- if(niza[i].lk) vmetni(rlk,niza[i]);
- else
- if(niza[i].p) vmetni(rp,niza[i]);
- else
- if(niza[i].vd) vmetni(rvd,niza[i]);
- /*cout<<"Ako nema povekje lugje pritisni t"<<endl;
- cin>>znak;
- if(znak=='t') break;
- }*/
- }
- opsluzuva(rlk,rp,rvd);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement