Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Glavni program
- #include <iostream>
- using namespace std;
- struct car {
- double serial_number;
- char brand [20];
- char model[20];
- int year;
- };
- typedef car elementtype;
- //#include "stog_pokazivac.h"
- #include "stog_polje.h"
- int storage(S_stack *skladiste, elementtype temporary) {
- cout<<"\nUnesite serijski broj auta: "; cin>>temporary.serial_number;
- cout<<"Unesite proizvodaca auta: "; cin>>temporary.brand;
- cout<<"Unesite model auta: "; cin>>temporary.model;
- do{
- cout<<"Unesite godinu proizvodnje auta: "; cin>>temporary.year;
- if (temporary.year < 1995 || temporary.year > 2010)
- cout<<"Godina mora biti u rasponu 1995-2010."<<endl;
- } while (temporary.year < 1995 || temporary.year > 2010);
- PushS(temporary, skladiste);
- return 0;
- }
- int unloading1 (S_stack *skladiste,S_stack *PomStack){
- cout<<"Auto kuca 1 (iskrcaj autiju starijih od 2006 koji nisu Audi"<<endl;
- while (IsEmptyS(skladiste)==0 ){
- if (TopS(skladiste).year>2006 && strcmp(TopS(skladiste).brand,"Audi")){
- cout<<"\n############# Iskrcaj auta "<<TopS(skladiste).serial_number<<" ###########"<<endl;
- cout<<TopS(skladiste).brand<<" "<<TopS(skladiste).model<<" , proizveden "<<TopS(skladiste).year<<endl;
- cout<<"############################################\n"<<endl;
- PopS(skladiste);
- }
- else {
- PushS( TopS(skladiste), PomStack);
- PopS(skladiste);
- }
- };
- cout<<"Stanje na skladistu"<<endl;
- while ( IsEmptyS(PomStack)==0 ){
- PushS( TopS(PomStack), skladiste);
- cout<<TopS(skladiste).serial_number<<"\t"<<TopS(skladiste).brand<<" "<<TopS(skladiste).model<<", proizveden "<<TopS(skladiste).year<<endl;
- PopS(PomStack);
- }
- }
- int kraj=0;
- int unloading2(S_stack *skladiste, elementtype temporary){
- temporary=TopS(skladiste);
- PopS(skladiste);
- if (!IsEmptyS(skladiste) || kraj==1) unloading2 (skladiste, temporary);
- kraj = 1;
- if (!strcmp(temporary.brand,"Audi")){
- cout<<"\n############### Iskrcaj auta "<<temporary.serial_number<<" ###########"<<endl;
- cout<<temporary.brand<<" "<<temporary.model<<" , proizveden "<<temporary.year<<endl;
- cout<<"############################################\n"<<endl;
- }
- else{
- PushS(temporary, skladiste);
- cout<<TopS(skladiste).serial_number<<" "<<TopS(skladiste).brand<<" "<<TopS(skladiste).model<<", proizveden "
- <<TopS(skladiste).year<<" ostaje na skladistu "<<endl;
- } }
- int main(){
- int i,br, izbor, izbor2;
- elementtype temporary;
- S_stack *skladiste, *PomStack;
- skladiste=InitS();
- PomStack=InitS();
- cout<<"Koliko autiju prevozite" <<endl;
- cin>>br;
- cout<<"Unesite podatke o autima koje ukrcavate"<<endl;
- for (i=0;i<br;i++) storage(skladiste, temporary);
- cout<<"\nAuti ukrcani"<<endl;
- cout<<"Izaberite rutu: "<<endl;
- cout<<"1. auto kuca 1 (iskrcaj autiju proizvedenih nakon 2006 (ne audi)"<<endl;
- cout<<"2. auto kuca 2 (iskrcaj Audija"<<endl;
- cin>>izbor;
- switch (izbor){
- case 1: unloading1 (skladiste,PomStack); break;
- case 2: unloading2 (skladiste,temporary); break;
- };
- cout<<"\n\}Kraj rada ili odlazak i u drugu autu kucu??"<<endl;
- cout<<"1. Nastavak puta i odlazak u drugu auto kucu"<<endl;
- cout<< "2. Kraj"<<endl;
- cin>>izbor2;
- switch (izbor2){
- case 1: if(izbor==1) {
- cout<<"Auto kuca 2 (iskrcaj autiju proizvodaca Audi\n"<<endl;
- unloading2(skladiste,temporary);
- }
- else unloading1 (skladiste,PomStack);
- break;
- }
- system ("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment