/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> using namespace std; struct elementtype { int sbroj; char proiz[20]; char model[20]; int godina; }; struct list { elementtype element; list *next; }; struct stack { list st; list *top; }; void Init(stack *S) { S->top = NULL; S->st.next = NULL; } void Push(elementtype x, stack *S) { list *newElement = new list; newElement->next = S->top; newElement->element = x; S->top = newElement; } elementtype Top(stack *S) { return S->top->element; } bool IsEmpty(stack *S) { if(S->top == NULL) { return true; } else { return false; } } void Pop(stack *S) { if(IsEmpty(S)) { cout << "Stog je prazan." << endl; } else { delete S->top; S->top = S->top->next; } }