Skip to content

Instantly share code, notes, and snippets.

@foca
Forked from wycats/touchnotes.py
Created July 21, 2008 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foca/47 to your computer and use it in GitHub Desktop.
Save foca/47 to your computer and use it in GitHub Desktop.
#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);
}
#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