#C9598. Reverse the Characters of Each Word
Reverse the Characters of Each Word
Reverse the Characters of Each Word
Given a string consisting of words separated by a single space, reverse the characters in each word without changing the order of the words. In other words, if you are given a string \( s = w_1\ w_2\ \ldots\ w_n \), you need to compute a new string \( s' = w_1'\ w_2'\ \ldots\ w_n' \) where each \( w_i' \) is the reversal of \( w_i \) (i.e., \( w_i' = \text{reverse}(w_i) \)).
For example, if the input is hello world
, the output should be olleh dlrow
(since \( \text{reverse}(\text{'hello'}) = \text{'olleh'} \) and \( \text{reverse}(\text{'world'}) = \text{'dlrow'} \)).
inputFormat
The input is given as a single line read from standard input. This line is a string containing one or more words separated by single spaces. If the input is an empty string, you should output an empty string.
outputFormat
Output the transformed string on standard output where each word's characters have been reversed but the words retain their original order.
## samplehello world
olleh dlrow