Problema
Ver traduçãoConvert text to title case: the first letter of every word becomes uppercase and the remaining letters lowercase. Words are separated by single spaces.
Implement title_case(text).
Input
text: Lowercase or mixed-case words separated by single spaces.
Output
Return the title-cased text.
Restrições
0 ≤ length ≤ 10,000 (letters and spaces)
Exemplos
Entrada:
text = "hello world"
Saída esperada:
expected = "Hello World"
Entrada:
std::string text = "hello world";
Saída esperada:
std::string expected = "Hello World";
Entrada:
string text = "hello world";
Saída esperada:
string expected = "Hello World";
Explicação
"hello" → "Hello" and "world" → "World".
Entrada:
text = "tHE qUICK fox"
Saída esperada:
expected = "The Quick Fox"
Entrada:
std::string text = "tHE qUICK fox";
Saída esperada:
std::string expected = "The Quick Fox";
Entrada:
string text = "tHE qUICK fox";
Saída esperada:
string expected = "The Quick Fox";
Explicação
Remaining letters become lowercase: "The Quick Fox".
Referências
Este desafio foi adaptado para o CodeUtility. Siga o enunciado e as restrições acima.