#K70862. Reverse Words in a Sentence
Reverse Words in a Sentence
Reverse Words in a Sentence
Given a sentence, reverse each word individually while keeping the words in their original positions. For example, if the input sentence is Hello from the other side
, then the output should be olleH morf eht rehto edis
.
This problem requires processing a single line of text from standard input and printing the result to standard output. Note that punctuation and case should be treated as part of the word. No extra formatting or additional characters should be added to the output.
Mathematically, if a word is represented as a string \(W = w_1w_2...w_n\), the reverse of the word is \(W^{R} = w_n...w_2w_1\). The final output for a sentence with words \(W_1, W_2, ..., W_k\) is:
\[ Output = W_1^{R} \; \text{concatenated with a single space}\; W_2^{R} \; \text{concatenated with a space}\; ... \; W_k^{R} \]inputFormat
The input consists of a single line containing the sentence. The sentence can be empty, or it can contain letters, punctuation, and spaces.
outputFormat
Output the sentence after reversing each word individually. The words should remain in the same order as in the input.
## sampleHello
olleH
</p>