print stack from bottom to top code example
Example: print stack from bottom to top
void PrintStack(stack<int> s)
{
if (s.empty())
return;
int x = s.top();
s.pop();
PrintStack(s);
cout << x << " ";
s.push(x);
}
void PrintStack(stack<int> s)
{
if (s.empty())
return;
int x = s.top();
s.pop();
PrintStack(s);
cout << x << " ";
s.push(x);
}