Pregled posta

Adresa bloga: https://blog.dnevnik.hr/prirodaa

Marketing

stog,jednostruka

#include
#include
using namespace std;

struct node
{ int data;
node *link;
};
//DEKLARACIJE FUNKCIJA
bool stackEmpty(node*);
void push(node*&, int);
int pop(node*&);
void write(node*);
void deleteStack(node*&);

int main(){
node *stack = NULL;
int elt=1;
char odabir;
do
{
cout<<"\n\nI-Z-B-O-R-N-I-K"< cout<<"\n1 - Unos novog primjerka";
cout<<"\n2 - Preuzimanje artikla";
cout<<"\n3 - Ispis trenutnog stanja skladista";
cout<<"\n0 - Kraj";
cout<<"\n\nUnesite Vas odabir...\n";
cin>>odabir;
switch(odabir)
{
case '1':
push(stack,elt);
elt++;
cin.get();
break;
case '2':
if(!stackEmpty(stack))
{
cout<<"Preuzet je artikl pod rednim brojem..."< elt--;
}
else cout<<"Skladiste je prazno. Nemate sto preuzeti"< cin.get();
break;
case '3':
if(!stackEmpty(stack)) write(stack);
else cout<<"Skladiste je prazno."< cin.get();
break;
case '0':
cout<<"Kraj programa.\n";
}
}
while(odabir!='0');
//DEALOKACIJA
deleteStack(stack);
cin.sync();
cin.get();
return 0;
}
bool stackEmpty(node *head)
{
return (head==0);
}

void push(node *&head, int elt)
{
node *newNode=new node;
newNode->data=elt;
newNode->link=head;
head=newNode;
}
int pop(node *&head)
{
int elt=head->data;
node *tmp=head;
head=head->link;
delete tmp;
return elt;
}

void write(node *head)
{
while (head)
{
cout<data;
head=head->link;
}
cout< }
void deleteStack(node *&head)
{
node *tmp;
while(head)
{
tmp=head;
head=head->link;
delete tmp;
}
head=NULL;
}



Post je objavljen 05.06.2012. u 10:54 sati.