/ Published in: C++
Glavni dio programa za drugu zadacu iz kolegija Strukture podataka
Expand |
Embed | Plain Text
#include<iostream> //#include"stog_polje.h" #include"stog_pokazivac.h" using namespace std; void unos_skladiste(stog *S) { char jos; tskladiste x; cout << "Proizvodac: " ; cin.ignore(); cin.getline(automobil.proizvodac, 20); do{ cout << "Serijski broj: "; cin >> automobil.serijskibr; cout << "Model: "; cin.ignore(); cin.getline(automobil.model, 20); do { cout << "Godina proizvodnje (1995-2010): "; cin >> automobil.godpro; if (automobil.godpro < 1995 || automobil.godpro>2010) cout << "Godina proizvodnje nije u rasponu od 1995 do 2010. Ponovite unos! " << endl; } while (automobil.godpro < 1995 || automobil.godpro>2010); cout << "Zelite li unijeti jos modela istog proizvodjaca?(d/n) "; cin >> jos; PushS(automobil, S); }while(jos=='d'); cout << endl; }; void lista(stog* S) { tskladiste pom[25]; int br=0; while(!IsEmptyS(S)){ automobil = TopS(S); pom[br] = automobil; br++; PopS(S); } for (int i=br-1;i>=0;i--) { cout << "Serijski broj: " << pom[i].serijskibr << endl; cout << "Proizvodac: " << pom[i].proizvodac << endl; cout << "Model: " << pom[i].model << endl; cout << "Godina proizvodnje: " << pom[i].godpro << endl; cout << endl; automobil = pom[i]; PushS(automobil, S); } } void prvi_autosalon (stog *S, stog* pomocni) { if(!IsEmptyS(S)) { tskladiste 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.godpro>2006 && strcmp(pom.proizvodac,"Audi")!=0){ cout << "Serijski broj: " << pom.serijskibr << endl; cout << "Proizvodac: " << pom.proizvodac << endl; cout << "Model: " << pom.model << endl; cout << "Godina proizvodnje: " << pom.godpro << endl; cout << endl; } } while(!IsEmptyS(pomocni)) { pom = TopS(pomocni); PopS(pomocni); if(pom.godpro<=2006 || strcmp(pom.proizvodac,"Audi")==0) PushS(pom,S); } cout << "U kamionu ostaju automobili: " << endl; lista(S); }else cout<<"U kamionu nema automobila!\n"; } void drugi_autosalon(stog *S) { if(!IsEmptyS(S)) { tskladiste pom = TopS(S); if(!strcmp(pom.proizvodac,"Audi")){ cout << "Serijski broj: " << pom.serijskibr << endl; cout << "Proizvodac: " << pom.proizvodac << endl; cout << "Model: " << pom.model << endl; cout << "Godina proizvodnje: " << pom.godpro << endl; cout << endl; } PopS(S); if(!IsEmptyS(S)) drugi_autosalon(S); if(strcmp(pom.proizvodac,"Audi")) PushS(pom, S); } }; int main() { int izbor; stog *S = InitS(S); stog *pomocni = InitS(pomocni); cout<<"\n****Simulacija - ukrcaj, transport, iskrcaj automobila*****\n"; do { cout << "\n***IZBORNIK***\n"; cout << "1) Automobili u skladistu (ukrcavanje na kamion)\n" ; cout << "2) Prvi autosalon\n" ; cout << "3) Drugi autosalon\n" ; cout << "4) Kraj programa\n" ; cout << "Vas izbor je: \n"; cin >> izbor; switch (izbor) { case 1: unos_skladiste(S); cout << endl; break; case 2: cout << "**Iskrcaj u prvom autosalonu**\n"; cout << "===Iskrcavanje automobila iz kamiona===\n"; prvi_autosalon(S,pomocni); cout << "===Automobili ostaju u kamionu===\n"; cout << endl; break; case 3: cout << "**Iskrcaj u drugom autosalonu**\n"; cout<<"===Iskrcavanje automobila iz kamiona=== \n"; drugi_autosalon(S); cout << "===Automobili ostali u kamionu=== \n"; lista(S); cout << endl; break; case 4: break; default: cout<<"Krivi unos! Pokusajte ponovno!"<<endl; } } while (izbor!=4); system("pause"); return 0; }
You need to login to post a comment.
