/ Published in: C++
Expand |
Embed | Plain Text
#include<iostream> #include"stog_polje.h" //#include"stog_pokazivac.h" using namespace std; void unos (stog* S){ char jos; cout << "Proizvodjac: "; cin.ignore(); cin.getline(automob.proizvodac, 15); do{ cout << "Serijski broj: "; cin >> automob.serijski_br; cout << "Model: "; cin.ignore(); cin.getline(automob.model, 15); do { cout << "Godina proizvodnje (1995-2010): "; cin >> automob.god_proizvodnje; if (automob.god_proizvodnje < 1995 ||automob.god_proizvodnje>2010) cout << "Godina proizvodnje nije u rasponu od 1995 do 2010. Ponovite unos! " << endl; } while (automob.god_proizvodnje < 1995 ||automob.god_proizvodnje>2010); cout << "Zelite li unijeti jos modela istog proizvodjaca?(d/n) "; cin >> jos; PushS(automob, S); }while(jos=='d'); cout << endl; } void ispis(stog* S) { t_auto pomocna[25]; int br=0; while(!IsEmptyS(S)){ automob = TopS(S); pomocna[br] = automob; br++; PopS(S); } for (int i=br-1;i>=0;i--) { cout << "Serijski broj: " << pomocna[i].serijski_br << endl; cout << "Proizvodac: " << pomocna[i].proizvodac << endl; cout << "Model: " << pomocna[i].model << endl; cout << "Godina proizvodnje: " << pomocna[i].god_proizvodnje << endl; cout << endl; automob = pomocna[i]; PushS(automob, S); } } void auto_kuca1 (stog *S, stog* pomocni) { if(!IsEmptyS(S)) { t_auto pom; cout << "**Iskrcaj u prvoj auto kuci**" << endl; cout<<"-->Automobili koji se iskrcavaju:"<<endl; while(!IsEmptyS(S)){ pom = TopS(S); PopS(S); PushS(pom, pomocni); if(pom.god_proizvodnje>2006 && strcmp(pom.proizvodac,"Audi")!=0){ cout << "Serijski broj: " << pom.serijski_br << endl; cout << "Proizvodac: " << pom.proizvodac << endl; cout << "Model: " << pom.model << endl; cout << "Godina proizvodnje: " << pom.god_proizvodnje << endl; cout << endl; } } while(!IsEmptyS(pomocni)) { pom = TopS(pomocni); PopS(pomocni); if(pom.god_proizvodnje<=2006 || strcmp(pom.proizvodac,"Audi")==0) PushS(pom,S); } cout << "-->U kamionu ostaju ovi automobili: " << endl; ispis(S); }else cout<<"-->U kamionu nema automobila!\n"; } void auto_kuca2(stog* S) { if(!IsEmptyS(S)) { t_auto pom = TopS(S); if(!strcmp(pom.proizvodac,"Audi")){ cout << "Serijski broj: " << pom.serijski_br << endl; cout << "Proizvodac: " << pom.proizvodac << endl; cout << "Model: " << pom.model << endl; cout << "Godina proizvodnje: " << pom.god_proizvodnje << endl; cout << endl; } PopS(S); if(!IsEmptyS(S)) auto_kuca2(S); if(strcmp(pom.proizvodac,"Audi")) PushS(pom, S); } } int main () { int izbor; stog *S = InitS(S); stog *pomocni = InitS(pomocni); cout<<"Autor: Monika Cerjak"<<endl; cout<<"****Simulacija - ukrcaj, transport, iskrcaj automobila*****"<<endl<<endl; do { cout << "----IZBORNIK----" << endl; cout << "1) Upis automobila (ukrcavanje na kamion)" << endl; cout << "2) Iskrcaj automobila u prvoj auto kuci" << endl; cout << "3) Iskrcaj automobila u drugoj auto kuci" << endl; cout << "4) Izlaz iz programa" << endl; cout << "Vas izbor je: "; cin >> izbor; cout << endl; switch (izbor) { case 1: unos(S); cout << endl; break; case 2: auto_kuca1(S,pomocni); cout << endl; break; case 3: cout << "**Iskrcaj u drugoj auto kuci**" << endl; cout<<"-->Automobili koji se iskrcavaju:"<<endl; auto_kuca2(S); cout << "-->U kamionu su ostali ovi automobili: " << endl; ispis(S); cout << endl; break; case 4: break; default: cout<<"Krivi unos! Pokusajte ponovno!"<<endl; } } while (izbor!=4); return 0; }
You need to login to post a comment.
