Reversing a list of words (2)

Write a program that reads a sequence of words until the first appearance of the word “end”, and prints it reversed.

Input

Input consists of a sequence of words. At least one is “end”.

Output

Print all the words of the original sequence until the first appearance of “end”, in reverse order, and one per line.

Observation

For the sake of practice, use recursion (not arrays).

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T11:12:41.430Z

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