#C5666. Reverse Words in a String
Reverse Words in a String
Reverse Words in a String
Given a string consisting of words separated by spaces, your task is to reverse every word in the string while maintaining the original order of the words. For each word, all characters (including punctuation) are reversed.
Example: If the input is "hello world", the output should be "olleh dlrow".
This problem tests your ability to manipulate strings and handle input/output via standard streams.
inputFormat
The input consists of a single line read from stdin
which contains words separated by a single space. The string may be empty.
outputFormat
Output a single line to stdout
where every word from the input has been reversed, but the order of the words remains unchanged.
hello world
olleh dlrow