Girant una llista de paraules (2) P52926


Statement
 

pdf   zip

html

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).

Public test cases
  • Input

    jordi
    mireia
    arnau
    end
    

    Output

    arnau
    mireia
    jordi
    
  • Input

    dolphins
    octopuses
    squid
    sharks
    noodles
    whales
    piranhas
    killerwhales
    end
    langoustines
    prawns
    end
    end
    shrimps
    

    Output

    killerwhales
    piranhas
    whales
    noodles
    sharks
    squid
    octopuses
    dolphins
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Python