#C14733. Reverse Words Order
Reverse Words Order
Reverse Words Order
Given a string s, reverse the order of its words while keeping the characters within each word in the same order. Words are defined as sequences of non-space characters. The input may contain leading or trailing spaces and multiple spaces between words. The output should have the words in reversed order separated by a single space.
For example, if the input is "The quick brown fox", the output should be "fox brown quick The".
Note: Use \(\text{split()}\)
and \(\text{join()}\)
operations accordingly for languages that support them.
inputFormat
The input consists of a single line containing a string s which may include spaces and punctuation. You should read the entire line as input from stdin
.
outputFormat
Output the string with the order of words reversed. The words in the output should be separated by a single space. Write the result to stdout
.
hello
hello