#C4473. Reverse Words in a Sentence
Reverse Words in a Sentence
Reverse Words in a Sentence
This problem requires you to take a sentence and reverse the characters of each individual word while maintaining the original order of the words. For example, given the sentence Hello World from AI, you should output olleH dlroW morf IA.
Note that the sentence may be empty, and words are assumed to be separated by spaces. Ensure that you only reverse the characters in each word and do not change the order of the words.
In formulaic terms, if a sentence is given by
\( S = w_1 \; w_2 \; \dots \; w_n \),
the output should be
\( S' = reverse(w_1) \; reverse(w_2) \; \dots \; reverse(w_n) \).
inputFormat
The input consists of a single line of text containing a sentence S. The sentence may be empty, and words are separated by spaces.
outputFormat
Output the sentence with each word's characters reversed, while preserving the original order of the words.## sample
Hello
olleH