Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct elem
- {
- int i;
- elem*next;
- };
- bool pop (elem*h, int&a);
- void push (elem*&h, int a);
- int main ()
- {
- int a=1;
- elem* str1=0;
- push (str1, a);
- if (!pop(str1, a))
- cout<<"Str is emty!";
- std::cin.sync();
- std::cin.clear();
- std::cin.get();
- return 0;
- }
- bool pop (elem*h, int&a)
- {
- if (h)
- {
- elem* tp = h -> next;
- int t= h -> i;
- delete h;
- h=tp;
- return t;
- }
- return false;
- }
- void push (elem*&h, int a)
- {
- elem*p=new elem;
- p->i=a;
- p->next=h;
- h=p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement