-
-
Save foca/47 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
struct Automobil{ | |
int ser_broj; | |
char proizvodjac[50]; | |
char model[50]; | |
int godina; | |
}; | |
typedef Automobil elementtype; | |
struct st { | |
elementtype value; | |
struct st *next; | |
}; | |
typedef struct st stack; | |
typedef stack *element; | |
elementtype TopS(stack *S) { | |
if ((*S).next == NULL) { | |
cout << "Stog je prazan." << endl; | |
return(0); | |
} | |
else | |
return((*(*S).next).value); | |
} | |
void PushS(elementtype x,stack *S) { | |
element e; | |
e =(struct st *)malloc(sizeof(struct st)); | |
(*e).value=x; | |
(*e).next=(*S).next; | |
(*S).next=e; | |
} | |
void PopS(stack *S) { | |
element e; | |
e =(*S).next; | |
(*S).next =(*(*S).next).next; | |
free(e); | |
} | |
void InitS(stack *S) { | |
(*S).next=NULL; | |
} | |
element IsEmptyS(stack *S) { | |
if ((*S).next==NULL){ | |
return(-1); | |
} | |
else return(0); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
struct Automobil{ | |
int ser_broj; | |
char proizvodjac[50]; | |
char model[50]; | |
int godina; | |
}; | |
typedef Automobil elementtype; | |
typedef int element; | |
struct st { | |
elementtype elements[10000]; | |
element top; | |
}; | |
typedef struct st stack; | |
elementtype TopS(stack *S) { | |
if ((*S).top<9999) | |
return((*S).elements[(*S).top+1]); | |
else { | |
cout<<"Stog je prazan."<<endl; | |
return(0); | |
} | |
} | |
void PushS(elementtype x,stack *S) { | |
if ((*S).top >= 0) { | |
(*S).elements[(*S).top]=x; | |
(*S).top--; | |
} | |
else { | |
cout << "Stog je popunjen." << endl; | |
exit(1); | |
} | |
} | |
void PopS(stack *S) { | |
if ((*S).top<9999) | |
(*S).top++; | |
else { | |
cout<< "Stog je prazan." << endl; | |
exit(0); | |
} | |
} | |
void InitS(stack *S) { | |
(*S).top=9999; | |
} | |
element IsEmptyS(stack *S) { | |
if ((*S).top==9999){ | |
return(-1); | |
} | |
else return(0); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment