CJCoding With Joseph
15free / daySign inCreate account

Push All from a Vector

Write 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 — print one after the last line.

Hints2 available
Topics:
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.