leetcode709—To Lower Case

leetcode709—To Lower Case

Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.

Example 1: Input: "Hello" Output: "hello"

Example 2: Input: "here" Output: "here"

Example 3: Input: "LOVELY" Output: "lovely" 想法:利用c++里面的函数transform,进行大小写转换。

transform(str.begin(), str.end(), str.begin(), ::toupper);变成大写
transform(str.begin(), str.end(), str.begin(), ::tolower);变成小写

class Solution { public: string toLowerCase(string str) { transform(str.begin(), str.end(), str.begin(), ::tolower); return str; } };


转载于:https://www.cnblogs.com/tingweichen/p/10205907.html