Push All from a Vector
easyQuestion 508Write a function void pushAll(stack<int>& s, const vector<int>& v) that pushes every element of v onto s, in order from v[0] to the last element (so the last element of v ends up on top). The loop header is already written.
The tests then print the top and the size of the stack, for example for an empty stack and v = {4, 5, 9} (see Expected Output).
Do NOT write a main function.
Expected output
Top: 9 Size: 3 Top: 40 Size: 4
= newline. The output ends with a newline, so print one after the last line.
Hints2 available
Sign in to use hintsTopics
STL ContainersStacks
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your output
Run your code to see the output here...
Test cases
Run your code to see test case results.