how to access stack elements in c++ code example
Example 1: stack c++
#include
stack stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5
Example 2: c++ insertion in astack
stack a;
a.push(5);
a.push(6);
//.....
#include
stack stk;
stk.push(5);
int ans = stk.top(5); // ans =5
stk.pop();//removes 5
stack a;
a.push(5);
a.push(6);
//.....