Reversing a list of words (4) P38877


Statement
 

pdf   zip

html

Write a program that reads a number n and a sequence of n or more words, and prints the n ‍last words in reverse order.

Input

Input begins with a natural number n, followed by, at least, n words.

Output

Print the last n words of the original sequence, in reverse order, and one per line.

Observation

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

Public test cases
  • Input

    2
    tom
    anne
    arnold
    

    Output

    arnold
    anne
    
  • Input

    4
    dolphins
    octopuses
    squid
    sharks
    whales
    piranhas
    killerwhales
    fish
    

    Output

    fish
    killerwhales
    piranhas
    whales
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Haskell Python