Đề bài
Xem bản dịchConvert 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.
Ràng buộc
0 ≤ length ≤ 10,000 (letters and spaces)
Ví dụ
Đầu vào:
text = "hello world"
Kết quả mong đợi:
expected = "Hello World"
Đầu vào:
std::string text = "hello world";
Kết quả mong đợi:
std::string expected = "Hello World";
Đầu vào:
string text = "hello world";
Kết quả mong đợi:
string expected = "Hello World";
Giải thích
"hello" → "Hello" and "world" → "World".
Đầu vào:
text = "tHE qUICK fox"
Kết quả mong đợi:
expected = "The Quick Fox"
Đầu vào:
std::string text = "tHE qUICK fox";
Kết quả mong đợi:
std::string expected = "The Quick Fox";
Đầu vào:
string text = "tHE qUICK fox";
Kết quả mong đợi:
string expected = "The Quick Fox";
Giải thích
Remaining letters become lowercase: "The Quick Fox".
Tham khảo
Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.