โจทย์
ดูฉบับแปล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 กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน