Return to Snippet

Revision: 35941
at November 15, 2010 08:35 by spicko


Updated Code
struct auti {
       int serijski_broj;
       char proizvodac [30];
       char model_automobila[25];
       int godina_proizvodnje;
       };
typedef auti elementtype;

struct smth{
    elementtype vrijednost;
    struct smth *slijedeci;
};

typedef struct smth stog;

elementtype TopS(stog *L){
    stog *vrh;
    if(L->slijedeci==NULL){
        cout<<"Greska, stog je prazan!"<<endl;
        exit(1);
    };
    vrh=L->slijedeci;
    return vrh->vrijednost;
};

void PushS(elementtype z, stog *L){
    stog *novi;
    novi=(stog *)malloc(sizeof(stog));
    novi->vrijednost=z;
    novi->slijedeci=L->slijedeci;
    L->slijedeci=novi;
};

void PopS(stog *L){
    stog *pri;
    if(L->slijedeci==NULL){
        cout<<"Greska, 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;
};

int IsEmptyS(stog *L){
    if(L->slijedeci==NULL) return 1;
    else return 0;
};

Revision: 35940
at November 15, 2010 08:17 by spicko


Initial Code
struct auti {
       int serijski_broj;
       char proizvodac [30];
       char model_automobila[25];
       int godina_proizvodnje;
       };
typedef auti elementtype;

struct smth {
    elementtype vrijednosti[5000];
    int vrh;
};

typedef struct smth stog;

elementtype TopS(stog *L){
    if(L->vrh==4999){
        cout<<"Greska, stog je prazan!"<<endl;
        exit(1);
    }
    return L->vrijednosti[L->vrh+1];
};

void PushS(elementtype z, stog *L){
    if(L->vrh==-1){
        cout<<"Greska, stog je pun!"<<endl;
        exit(1);
    };
    L->vrijednosti[L->vrh]=z;
    L->vrh--;
};

void PopS(stog *L){
    if(L->vrh==4999){
        cout<<"Greska, stog je prazan"<<endl;
        exit(1);
    };
    L->vrh++;
};

int IsEmptyS(stog *L){
    if(L->vrh==4999) return 1;
    else return 0;
};

stog * InitS(void){
    stog *L;
    L=(stog *)malloc(sizeof(stog));
    L->vrh=4999;
    return L;
};

Initial URL


Initial Description


Initial Title
SP zadaća 2 - biblioteka pokazivaci

Initial Tags


Initial Language
C++