Facile 0 risolte 0% di accettazione

Title Case

Capitalize the first letter of every word.

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.

Vincoli

0 ≤ length ≤ 10,000 (letters and spaces)

Esempi

Esempio 1
Input:
text = "hello world"

Output atteso:
expected = "Hello World"
Input:
std::string text = "hello world";

Output atteso:
std::string expected = "Hello World";
Input:
string text = "hello world";

Output atteso:
string expected = "Hello World";

Spiegazione

"hello" → "Hello" and "world" → "World".

Esempio 2
Input:
text = "tHE qUICK fox"

Output atteso:
expected = "The Quick Fox"
Input:
std::string text = "tHE qUICK fox";

Output atteso:
std::string expected = "The Quick Fox";
Input:
string text = "tHE qUICK fox";

Output atteso:
string expected = "The Quick Fox";

Spiegazione

Remaining letters become lowercase: "The Quick Fox".

Riferimenti

Questa sfida è adattata per CodeUtility. Segui la traccia e i vincoli sopra.

Impara dagli altri

Soluzioni della community

Nessuna soluzione pubblicata. Risolvi questa sfida per condividere la prima.