fork download
  1. #include<iostream>
  2. #include<stack>
  3. using namespace std;
  4.  
  5. void transfer(stack<int>s1, stack<int>s2){
  6. while(!s1.empty()){
  7. s2.push(s1.top());
  8. s1.pop();
  9. }
  10. }
  11. int main(){
  12. stack<int>s1;
  13. stack<int>s2;
  14. stack<int>s3;
  15. for(int i=0;i<5;i++){
  16. s1.push(i);
  17. }
  18.  
  19. transfer(s1,s2);
  20. transfer(s2,s3);
  21. transfer(s3,s1);
  22. while(!s1.empty()){
  23. cout<<s1.top();
  24. s1.pop();
  25. }
  26.  
  27. return 0;}
  28.  
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
43210