#C8623. Reverse Words in a Sentence
Reverse Words in a Sentence
Reverse Words in a Sentence
Given a string containing words separated by whitespace, your task is to reverse the order of the words. For example, if the input is hello world
, the output should be world hello
.
Note that the input may include extra spaces (leading, trailing, or in between words). Your solution should treat consecutive whitespace as a single separator.
Formally, if a string s contains words w1, w2, ..., wn separated by spaces, output the string wn ... w2 w1.
All formulas, if any, are given in LaTeX format, e.g. $w_1, w_2, \ldots, w_n$.
inputFormat
The input consists of a single line read from standard input (stdin). This line contains a string which may include leading, trailing, or multiple intermediate whitespace characters.
outputFormat
Output a single line to standard output (stdout) that contains the words of the input string in reverse order, separated by a single space.
## samplehello
hello