/ Published in: C++
Expand |
Embed | Plain Text
#include<iostream> //#include"polje.h" #include"pokazivac.h" using namespace std; void ispis(stog *S) { tautomobil pom[40]; int brojac=0; while(!IsEmptyS(S)){ automobil = TopS(S); pom[brojac] = automobil; brojac++; PopS(S); } for (int i=brojac-1;i>=0;i--) { cout<<"Serijski broj: "<<pom[i].sb<<endl; cout<<"Proizvodac: "<<pom[i].proizvodac<<endl; cout<<"Model: "<<pom[i].model<<endl; cout<<"Godina: "<<pom[i].godina<<endl<<endl; automobil = pom[i]; PushS(automobil, S); } } void unos (stog *S){ int jos; bool p=false; proizvodac: cout<<"proizvodac (veliko pocetno slovo): "; cin.ignore(); cin.getline(automobil.proizvodac, 30); model: cout<<"Model: "; if (p) cin.ignore(); cin.getline(automobil.model, 30); cout<<"Serijski broj: "; cin>>automobil.sb; do { cout<<"Godina proizvodnje: "; cin>>automobil.godina; if (automobil.godina < 1995 ||automobil.godina>2010) cout<<"Godina nije u rasponu! "<<endl; } while (automobil.godina < 1995 ||automobil.godina>2010); PushS(automobil, S); cout<<"Izaberite:"<<endl; cout<<"1.unos novog modela istog proizvodaca "<<endl; cout<<"2.unos novog modela drugog proizvodaca"<<endl; cout<<"3. kraj unosa "<<endl; cin>>jos; switch (jos){ case 1: p=true; goto model; break; case 2: p=false; goto proizvodac; break; default: cout<<"kraj unosa"<<endl<<endl<<endl; } } void prvi (stog *S, stog *pomocni) { if(!IsEmptyS(S)) { tautomobil pom; cout<<"----------Automobili koji izlaze--------------"<<endl; while(!IsEmptyS(S)){ pom = TopS(S); PopS(S); PushS(pom, pomocni); if(pom.godina>=2006) if (strcmp(pom.proizvodac,"Audi")){ cout<<"Serijski broj: "<<pom.sb << endl; cout<<"Proizvodac: "<<pom.proizvodac << endl; cout<<"Model: "<<pom.model << endl; cout<<"Godina: "<<pom.godina << endl<<endl; } } while(!IsEmptyS(pomocni)) { pom = TopS(pomocni); PopS(pomocni); if(pom.godina<2006 || !strcmp(pom.proizvodac,"Audi")) PushS(pom,S); } cout<<"----------------------------------------"<<endl; cout<<"automobili koji su ostali:"<<endl; ispis(S); cout<<"----------------------------------------"<<endl; } } void drugi(stog* S) { if(!IsEmptyS(S)) { tautomobil pom = TopS(S); if(!strcmp(pom.proizvodac,"Audi")){ cout<<"Serijski broj: "<<pom.sb<<endl; cout<<"Proizvodac: "<<pom.proizvodac<<endl; cout<<"Model: "<<pom.model<<endl; cout<<"Godina: "<<pom.godina<<endl<<endl;} PopS(S); if(!IsEmptyS(S)) drugi(S); if(strcmp(pom.proizvodac,"Audi")) PushS(pom, S); } } int main () { int izbor; stog *S = InitS(S); stog *pom = InitS(pom); do { cout<<"IZBORNIK: "<<endl; cout<<"---------------------------------"<<endl; cout<<"0. Izlaz"<<endl; cout<<"1. Unos automobila"<<endl; cout<<"2. Iskrcaj u prvoj autokuci (automobili proizvedeni poslije 2006 i nisu Audi)"<<endl; cout<<"3. Iskrcaj u drugoj autokuci (Audi svih godina)"<<endl; cout<<"---------------------------------"<<endl; cin>>izbor; switch (izbor) { case 1: unos(S); break; case 2: prvi(S,pom); break; case 3: cout<<"-------------------------------------------"<<endl; cout<<"isporuceni automobili: "<<endl; drugi(S); cout<<"--------------------------------------------------"<<endl; cout<<"automobili u kamionu: "<<endl; ispis(S); cout<<"---------------------------------------------------"<<endl; break; case 0: cout<<"Izkazim iz programa...."<<endl; break; default: cout<<"Krivi izbor !! "<<endl; } } while (izbor!=0); system ("pause"); return 0; }
You need to login to post a comment.
