Условие
Показать переводConvert 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.
Ограничения
0 ≤ length ≤ 10,000 (letters and spaces)
Примеры
Пример 1
Ввод:
text = "hello world"
Ожидаемый вывод:
expected = "Hello World"
Ввод:
std::string text = "hello world";
Ожидаемый вывод:
std::string expected = "Hello World";
Ввод:
string text = "hello world";
Ожидаемый вывод:
string expected = "Hello World";
Пояснение
"hello" → "Hello" and "world" → "World".
Пример 2
Ввод:
text = "tHE qUICK fox"
Ожидаемый вывод:
expected = "The Quick Fox"
Ввод:
std::string text = "tHE qUICK fox";
Ожидаемый вывод:
std::string expected = "The Quick Fox";
Ввод:
string text = "tHE qUICK fox";
Ожидаемый вывод:
string expected = "The Quick Fox";
Пояснение
Remaining letters become lowercase: "The Quick Fox".
Ссылки
Это задание адаптировано для CodeUtility. Следуйте условию и ограничениям выше.