Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```cpp
- struct nod {
- int inf;
- nod *next;
- };
- struct stiva {
- nod*vf;
- stiva()
- {
- vf = NULL;
- }
- void push(int k)
- {
- nod *y = new nod;
- y->inf=k;
- y->next = vf;
- vf = y;
- }
- bool isEmpty()
- {
- if (vf == NULL)
- return true;
- else
- return false;
- }
- void pop()
- {
- if (isEmpty() == false)
- {
- nod *y;
- y = vf;
- vf = vf->next;
- delete y;
- }
- else
- cout << "Stiva e goala ";
- }
- int top()
- {
- int k = vf->inf;
- return k;
- }
- };
- int main()
- {
- int n, m;
- stiva S;
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- cin >> m;
- S.push(m);
- }
- for (int i = 0; i < n; i++)
- {
- m=S.top();
- cout << m<<" ";
- S.pop();
- }
- _getch();
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement