Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- class stack
- {
- };
- int main( )
- {
- stack s1,s2;
- //s1 is your main stack
- //for pushing value:
- s1.push(value);
- //for poping value
- while(!s1.isEmpty())//push in temporary stack
- {
- int temp=s1.pop();
- s2.push(temp);
- }
- cout<<"1st value is : "<<s2.pop()<<endl;
- while(!s1.isEmpty())//again push in main stack
- {
- int temp=s2.pop();
- s1.push(temp);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement