Reversing a list of words (6) P89336


Statement
 

pdf   zip

thehtml

Write a program that reads a sequence of words and prints, in reverse order, the first half of the list.

Input

Input consists of a sequence of words.

Output

If n denotes the total number of words, print the ⌊ n/2 ⌋ first 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

    jordi
    mireia
    arnau
    

    Output

    jordi
    
  • Input

    dolphins
    octopuses
    squid
    sharks
    whales
    piranhas
    

    Output

    squid
    octopuses
    dolphins
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Python
    User solutions
    C C++ Haskell Python