#K52662. Reverse Words in a Sentence
Reverse Words in a Sentence
Reverse Words in a Sentence
Given a string s, reverse the letters of each word while preserving the word order. Formally, if a word is represented as $w = w_1w_2\cdots w_n$, its reversed form is $w_nw_{n-1}\cdots w_1$. For example, if s = "hello world"
, then the output should be "olleh dlrow"
.
The input will consist of a single line. You must process the string such that each word (substrings separated by spaces) is individually reversed, and then output the resulting string. Note that if the input is an empty string, the output should also be an empty string.
inputFormat
The input is read from standard input and consists of a single line s (possibly empty), representing the original string where words are separated by a single space.
outputFormat
Output the processed string to standard output, in which each word of the input has been reversed while keeping the original word order.
## samplehello world
olleh dlrow