#C14177. Reverse Characters in Each Word

    ID: 43797 Type: Default 1000ms 256MiB

Reverse Characters in Each Word

Reverse Characters in Each Word

Given a string, your task is to reverse the order of characters in each word while maintaining the original order of the words. Words are defined as sequences of non-space characters separated by one or more whitespace characters. For example, for the input string "Hello World", the expected output is "olleH dlroW". Note that extra spaces in the input should be treated as delimiters and should not appear in the output.

The operation for each word can be described by the formula: [ \text{reverse}(w) = (w_n, w_{n-1}, \dots, w_1)]

where (w) is a given word consisting of (n) characters.

inputFormat

The input consists of a single line containing the string to be processed. The string may include letters, digits, punctuation marks, and spaces. Extra spaces (leading, trailing, or multiple between words) should be ignored when generating the output.

outputFormat

Print a single line that is the transformed string, where each word has had its characters reversed, while the words remain in the original order and separated by a single space.## sample

Hello
olleH