#K78197. Capitalize Each Word
Capitalize Each Word
Capitalize Each Word
Given a string, your task is to capitalize the first letter of each word in the string. A word is defined as a contiguous sequence of non-space characters. After processing, the output should have exactly one space between words with no leading or trailing spaces.
For every word, apply the following transformation: \[ \text{CapitalizedWord} = \text{Upper}(\text{first character}) + \text{Lower}(\text{rest of the characters}) \]
For example, transforming "hello world" should yield "Hello World".
inputFormat
The input consists of a single line containing a string which may include leading, trailing, or multiple spaces between words. The string is read from standard input (stdin).
outputFormat
Output a single line containing the transformed string where the first letter of each word is capitalized and the remaining letters are in lowercase, with words separated by a single space. The output is printed to standard output (stdout).## sample
hello world
Hello World