#K15856. Reverse Words in Sentence
Reverse Words in Sentence
Reverse Words in Sentence
You are given a sentence. Your task is to reverse each word in the sentence while keeping the order of the words intact.
For example, given the input "Hello world!", the output should be "olleH !dlrow".
Note: The sentence is provided via standard input (stdin) and the transformed sentence should be printed to standard output (stdout).
The problem can be formally expressed as follows:
Let \( s \) be a string representing the sentence. For each word \( w \) in \( s \), compute its reverse \( w^R \), and then display the sentence formed by the sequence \( w_1^R, w_2^R, \dots, w_n^R \).
inputFormat
The input is provided via standard input (stdin) as a single line containing a sentence. The sentence may include letters, punctuation, and spaces. Note that extra leading and trailing spaces should be ignored in processing.
outputFormat
Output the transformed sentence to standard output (stdout) where each word in the original sentence is reversed while the word order is maintained.
## sampleHello world!
olleH !dlrow