#include<iostream>
#include<stack>
using namespace std;
int main(){
stack<int>mystack1;
stack<int>mystack2;
//pushing elements into first stack
mystack1.push(27);
mystack1.push(29);
mystack1.push(28);
//pushing elements into second stack
mystack2.push(34);
mystack2.push(33);
mystack2.push(35);
//using swap functions
mystack1.swap(mystack2);
// printing the first stack
cout<<"mystack1=";
while(!mystack1.empty()){
cout<<mystack1.top()<<" ";
mystack1.pop();
}
// printing the second stack
cout<<endl<<"mystack2= ";
while(!mystack2.empty()){
cout<<mystack2.top()<<" ";
mystack2.pop();
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: