Problem
Übersetzung anzeigenConvert 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.
Einschränkungen
0 ≤ length ≤ 10,000 (letters and spaces)
Beispiele
Eingabe:
text = "hello world"
Erwartete Ausgabe:
expected = "Hello World"
Eingabe:
std::string text = "hello world";
Erwartete Ausgabe:
std::string expected = "Hello World";
Eingabe:
string text = "hello world";
Erwartete Ausgabe:
string expected = "Hello World";
Erläuterung
"hello" → "Hello" and "world" → "World".
Eingabe:
text = "tHE qUICK fox"
Erwartete Ausgabe:
expected = "The Quick Fox"
Eingabe:
std::string text = "tHE qUICK fox";
Erwartete Ausgabe:
std::string expected = "The Quick Fox";
Eingabe:
string text = "tHE qUICK fox";
Erwartete Ausgabe:
string expected = "The Quick Fox";
Erläuterung
Remaining letters become lowercase: "The Quick Fox".
Referenzen
Diese Aufgabe wurde für CodeUtility angepasst. Beachte die oben genannten Vorgaben und Einschränkungen.