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