#K93067. Capitalize Words in a Sentence
Capitalize Words in a Sentence
Capitalize Words in a Sentence
Given a sentence, your task is to capitalize the first letter of each word. A word is defined as any sequence of characters separated by one or more spaces. The rest of the characters in each word should be converted to lowercase. For example, the word "WORD" should be converted to "Word".
Note: The input will be provided via standard input and may include extra spaces. Your output should be printed to standard output and must not include any leading or trailing spaces.
Mathematically, if the sentence is composed of words \(w_1, w_2, \dots, w_n\), the output sentence should be: \[ \text{output} = \text{Capitalize}(w_1) \;\cup\; \text{Capitalize}(w_2) \;\cup\; \dots \;\cup\; \text{Capitalize}(w_n) \] where \(\text{Capitalize}(w)\) converts the first character to uppercase and the rest to lowercase.
inputFormat
The input consists of a single line containing a sentence. The sentence may have extra spaces at the beginning, end, or between words.
Example:
hello world
outputFormat
Output the transformed sentence with the first letter of each word in uppercase and the remaining letters in lowercase. The words should be separated by a single space without any leading or trailing spaces.
Example:
Hello World## sample
hello world
Hello World