Problems
A substring of a string refers to a consecutive part of the string.
For example, "Jung" or "ngo" are substrings of "Jungol".
Using substrings effectively can make many string operations easier.
For example, when processing a sentence with spaces and separating it into words, substrings can simplify the task significantly.
Suppose you input the string "Jungol is the best" and assign it to a variable S.
Splitting the string by spaces and storing each word in an array word would give the following result:
word[0] = "Jungol"
word[1] = "is"
word[2] = "the"
word[3] = "best"
By finding the start index and length of each word, you can extract them using the substr function.
[Problem Task]
Write a program that:
Takes a sentence containing spaces as input.
Processes it to split the sentence into words.
Prints only the words in even positions (2nd, 4th, …), in reverse order of their input sequence.
Input
A string S (length ≤ 100) that may contain spaces.
Output
A single line containing the even-positioned words in reverse order, separated by spaces.
Example
Jungol is the best
best is