Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
stack::swap_30-Seconds-of-C++
#include <iostream> #include <stack> int main(){ std::stack<int> stack1; //pushing elements in stack1 using push() stack1.push(0); stack1.push(1); stack1.push(2); //elements of stack1: 0 1 2 std::stack<int> stack2; //pushing elements in stack2 using push() stack2.push(7); stack2.push(8); stack2.push(9); // elements of stack2: 7 8 9 stack1.swap(stack2); std::cout << "\nElements of stack1 after swap: "; while(!stack1.empty()) { std::cout << stack1.top() << " "; stack1.pop(); } std::cout << std::endl; std::cout << "\nElements of stack2 after swap: "; while(!stack2.empty()) { std::cout << stack2.top() << " "; stack2.pop(); } std::cout << std::endl; return 0; }
run
|
edit
|
history
|
help
0
CirclQ
FindMissingBinom
PreDir
Polyrmophism
exception
Изволов#8
always_late
MapTel2
Network UVa
Funny Saying