/ Published in: C++
Expand |
Embed | Plain Text
#include<iostream> #include"stog_polje.h" //#include"stog_pokazivac.h" using namespace std; void unos (stack* S){ cout << "Unesite serijski broj: "; cin >> automobil.sbr; cout << "Unesite proizvodaca: "; cin.ignore(); cin.getline(automobil.proizvodac, 30); cout << "Unesite model: "; cin.getline(automobil.model, 30); do { cout << "Unesite godinu proizvodnje: "; cin >> automobil.godina; if (automobil.godina < 1995 ||automobil.godina>2010) cout << "Godina mora biti u rasponu 1995-2010! Pokusajte ponovo! " << endl; } while (automobil.godina < 1995 ||automobil.godina>2010); PushS(automobil, S); } void ispis1 (stack *S, stack* pomocni) { if(!IsEmptyS(S)) { tautomobil pom; while(!IsEmptyS(S)){ pom = TopS(S); PopS(S); PushS(pom, pomocni); if(pom.godina>=2006) if(strcmp(pom.proizvodac,"Audi")){ cout << "Serijski broj: " << pom.sbr << endl; cout << "Proizvodac: " << pom.proizvodac << endl; cout << "Model: " << pom.model << endl; cout << "Godina: " << pom.godina << endl; } } while(!IsEmptyS(pomocni)) { pom = TopS(pomocni); PopS(pomocni); if(pom.godina<2006 || !(strcmp(pom.proizvodac,"Audi"))) PushS(pom,S); } } } void ispis2 (stack* S) { if(!IsEmptyS(S)) { tautomobil pom = TopS(S); if(!strcmp(pom.proizvodac,"Audi")){ cout << "Serijski broj: " << pom.sbr << endl; cout << "Proizvodac: " << pom.proizvodac << endl; cout << "Model: " << pom.model << endl; cout << "Godina: " << pom.godina << endl; } PopS(S); if(!IsEmptyS(S)) ispis2(S); if(strcmp(pom.proizvodac,"Audi")) PushS(pom, S); } } int main () { int izb; stack *S = InitS(S); stack *pomocni = InitS(pomocni); do { cout<<endl; cout << " I Z B O R N I K " << endl; cout << " 1. Unos podataka o automobilima " << endl; cout << " 2. Iskrcaj automobila u prvu auto kucu" << endl; cout << " 3. Iskrcaj automobila u drugu auto kucu" << endl; cout << " 9. Izlaz iz programa" << endl; cout << " Vas izbor: "; cin >> izb; switch (izb) { case 1: unos(S); cout <<"--------------------------------------------------------"<< endl; break; case 2: cout << " ***Iskrcaj automobila u prvoj auto kuci*** " << endl; ispis1 (S,pomocni); cout <<"--------------------------------------------------------"<< endl; break; case 3: cout << " ***Iskrcaj automobila u drugoj auto kuci*** " << endl; ispis2(S); cout <<"--------------------------------------------------------"<< endl; break; case 9: break; } } while (izb!=9); return 0; }
You need to login to post a comment.
