Printing stacks

Write a procedure

    void print_from_top_to_bottom(stack<int>& S);

that prints a line (end line included) with the elements of @S@ from the top to the bottom, separated by spaces.

Also, write a procedure

    void print_from_bottom_to_top(stack<int>& S);

that prints a line (end line included) with the elements of @S@ from the bottom to the top, separated by spaces.

Observations

Observation

You only need to submit the required procedures; your main program will be ignored.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:36:36.346Z

© Jutge.org, 2006–2026.
https://jutge.org