Skip to content

Instantly share code, notes, and snippets.

@augustl
Created July 20, 2008 20:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save augustl/24 to your computer and use it in GitHub Desktop.
Save augustl/24 to your computer and use it in GitHub Desktop.
Obj-c header file for cocoa app
#include <iostream>
using namespace std;
#include "stog_pokazivaci.h"
//#include "stog_polje.h"
int kraj_rek;
bool print;
void unosi(stog *Stog_m) {
elementtype dod;
int n;
cout<<"Koliko automobil zelite unesti?" <<endl;
cin >> n;
for (int i=0;i<n;i++){
cout<<"Unesite serijski broj automobila: "<<endl;
cin>>dod.serijski_broj;
cout<<"Unesite proizvodaca automobila: "<<endl;
cin>>dod.proizvodac;
cout<<"Unesite model automobila: "<<endl;
cin>>dod.model_automobila;
do{
cout<<"Unesite godinu proizvodnje automobila: "<<endl;
cin>>dod.godina_proizvodnje;
if (dod.godina_proizvodnje < 1995 || dod.godina_proizvodnje > 2010){
cout << "Pogresan unos!" << endl;
cout << "Godina mora biti u rasponu 1995-2010!" << endl;
cout << "Molim vas ponovite!" << endl;}
} while (dod.godina_proizvodnje < 1995 || dod.godina_proizvodnje > 2010);
cout << "~~~~~~Uneseni automobil uspjesno je spremljen u skladiste!!~~~~~~" << endl;
PushS(dod, Stog_m);
}
}
void ispis1 (stog *Stog_m,stog *Stog_m_mov){
cout << "--------------------Iskrcaj automobila--------------------"<<endl;
cout << "----------------------------------------------------------"<< endl;
cout << "Proizvodac" << "\t" << "Model automobila" << "\t" << "Godina proizvodnje" << "\t" << endl;
cout <<"----------" << "\t" << "----------------" << "\t" << "------------------" << "\t" << endl;
while ( IsEmptyS(Stog_m)==0 ){
if (TopS(Stog_m).godina_proizvodnje>2006 && strcmp(TopS(Stog_m).proizvodac,"audi")){
cout<< TopS(Stog_m).proizvodac<<"\t\t"<<TopS(Stog_m).model_automobila<<"\t\t\t"<<TopS(Stog_m).godina_proizvodnje<<"\t\t"<<endl;
PopS(Stog_m); }
else {
PushS( TopS(Stog_m), Stog_m_mov);
PopS(Stog_m);
}
};
cout << "----------------------------------------------------------"<<endl;
cout << endl;
cout << "Automobili su uspjesno iskrcani!!" << endl;
cout << endl;
cout << endl;
cout << "-------------------Preostali automobili-------------------"<< endl;
cout << "----------------------------------------------------------"<<endl;
cout << "Proizvodac" << "\t" << "Model automobila" << "\t" << "Godina proizvodnje" << "\t" << endl;
cout <<"----------" << "\t" << "----------------" << "\t" << "------------------" << "\t" << endl;
while ( IsEmptyS(Stog_m_mov)==0 ){
PushS( TopS(Stog_m_mov), Stog_m);
cout<<TopS(Stog_m).proizvodac<<"\t\t"<<TopS(Stog_m).model_automobila<<"\t\t\t"<<TopS(Stog_m).godina_proizvodnje<<"\t\t "<<endl;
PopS(Stog_m_mov);
}
cout <<"----------------------------------------------------------" << endl;
}
int ispis2(stog *Stog_m){
elementtype dod;
dod=TopS(Stog_m);
if (!strcmp(dod.proizvodac,"audi")) {
cout << "-----------------------------------"<<endl;
cout << "Iskrcaj automobila marke Audi: " << endl;
cout << "Model: " <<dod.model_automobila << endl;
cout << "Godina proizvodnje: " <<dod.godina_proizvodnje<<endl;
cout<< "-----------------------------------" <<endl;}
PopS(Stog_m);
if (!IsEmptyS(Stog_m) || kraj_rek) ispis2 (Stog_m);
kraj_rek = true;
if (strcmp(dod.proizvodac,"audi")){
PushS(dod, Stog_m);
if (print==false){
cout << endl;
cout << "-------------------Preostali automobili-------------------"<< endl;
cout << "----------------------------------------------------------"<<endl;
cout << "Proizvodac" << "\t" << "Model automobila" << "\t" << "Godina proizvodnje" << "\t" << endl;
print=true;
};
cout<<dod.proizvodac<<"\t\t"<<dod.model_automobila<<"\t\t\t"<<dod.godina_proizvodnje<<endl;
}
}
int main(){
int izbor;
stog *Stog_m, *Stog_m_mov;
Stog_m=InitS();
Stog_m_mov=InitS();
do{
cout << "-------------------------------------------------" << endl;
cout << "1. Dodavanje zapisa o automobilima" << endl;
cout << "2. Ispis automobila marke!=Audi" << endl;
cout << "3. Ispis automobila marke==Audi (rekruzije)" << endl;
cout << "9. izlaz "<<endl;
cout << "-------------------------------------------------" << endl;
cout << "Vas izbor je: " << endl;
cin>>izbor;
cout << endl;
switch(izbor){
case 1: unosi(Stog_m);
break;
case 2: ispis1 (Stog_m,Stog_m_mov);
break;
case 3: ispis2 (Stog_m);
break;
}
}while (izbor !=9);
system("pause");
return 1;
}
struct auti {
double serijski_broj;
char proizvodac [20];
char model_automobila[20];
int godina_proizvodnje;
};
typedef auti elementtype;
struct smth {
elementtype vrijednosti[5000];
int vrh;
};
typedef struct smth stog;
void PushS(elementtype z, stog *L){
if(L->vrh==-1){
cout<<"Doslo je do pogreske!! Stog je pun!!"<<endl;
exit(1);
};
L->vrijednosti[L->vrh]=z;
L->vrh--;
};
elementtype TopS(stog *L){
if(L->vrh==4999){
cout<<"Doslo je do pogreske!! Stog je prazan!!"<<endl;
exit(1);
}
return L->vrijednosti[L->vrh+1];
};
int IsEmptyS(stog *L){
if(L->vrh==4999) return 1;
else return 0;
};
void PopS(stog *L){
if(L->vrh==4999){
cout<<"Doslo je do pogreske!! Stog je prazan!!"<<endl;
exit(1);
};
L->vrh++;
};
stog * InitS(void){
stog *L;
L=(stog *)malloc(sizeof(stog));
L->vrh=4999;
return L;
};
struct auti {
double serijski_broj;
char proizvodac [30];
char model_automobila[30];
int godina_proizvodnje;
};
typedef auti elementtype;
struct smth{
elementtype vrijednost;
struct smth *slijedeci;
};
typedef struct smth stog;
void PushS(elementtype z, stog *L){
stog *novi;
novi=(stog *)malloc(sizeof(stog));
novi->vrijednost=z;
novi->slijedeci=L->slijedeci;
L->slijedeci=novi;
};
elementtype TopS(stog *L){
stog *vrh;
if(L->slijedeci==NULL){
cout<<"Doslo je do pogreske!! Stog je prazan!!"<<endl;
exit(1);
};
vrh=L->slijedeci;
return vrh->vrijednost;
};
void PopS(stog *L){
stog *pri;
if(L->slijedeci==NULL){
cout<<"Doslo je do pogreske!! Stog je prazan"<<endl;
exit(1);
};
pri=L->slijedeci;
L->slijedeci=pri->slijedeci;
free(pri);
};
int IsEmptyS(stog *L){
if(L->slijedeci==NULL) return 1;
else return 0;
};
stog * InitS(void){
stog *L;
L=(stog *)malloc(sizeof(stog));
// L->vrijednost=0;
L->slijedeci=NULL;
return L;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment