Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class stack
  5. {
  6.  
  7. };
  8.  
  9. int main( )
  10. {
  11. stack s1,s2;
  12.  
  13. //s1 is your main stack
  14. //for pushing value:
  15. s1.push(value);
  16. //for poping value
  17. while(!s1.isEmpty())//push in temporary stack
  18. {
  19. int temp=s1.pop();
  20. s2.push(temp);
  21. }
  22.  
  23. cout<<"1st value is : "<<s2.pop()<<endl;
  24.  
  25. while(!s1.isEmpty())//again push in main stack
  26. {
  27. int temp=s2.pop();
  28. s1.push(temp);
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement