/ Published in: C++

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
struct auti { double ser_br; char proizvodac [30]; char model[30]; int god_pro; }; 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; }; int IsEmptyS(stog *L){ if(L->slijedeci==NULL) return 1; else return 0; }; 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); }; stog * InitS(void){ stog *L; L=(stog *)malloc(sizeof(stog)); L->slijedeci=NULL; return L; };
Comments
