/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include<iostream> #define n 50 using namespace std; struct elementtype { int sbroj; char proiz[20]; char model[20]; int godina; }; struct stack { elementtype st[n]; int cursor; }; void Init(stack *S) { S->cursor = n - 1; } bool IsEmpty(stack *S) { if(S->cursor >= n - 1) { return true; } else { return false; } } void Push(elementtype x, stack *S){ if(S->cursor == 0) cout << "Stog je pun" << endl; else { S->cursor--; S->st[S->cursor] = x; } }; elementtype Top(stack *S) { if(IsEmpty(S)) cout << "Nema zapisa\n"; else return S->st[S->cursor]; } void Pop(stack *S){ if(IsEmpty(S)) cout << "\nNema zapisa!\n"; else { S->cursor++; } }