Answers for "c++ print stack from top to bottom"

C++
0

c++ print stack from top to bottom

void PrintStack(stack<int> s)
{
    if (s.empty())
        return;
    int x = s.top();
    s.pop();
    cout << x << ' ';
    PrintStack(s);
    s.push(x);
}
Posted by: Guest on April-08-2021

Browse Popular Code Answers by Language