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++
class Solution {
public:
string toLowerCase(string str) {
string res = "";
for(int s : str){
if(s>= 'A' && s <= 'Z')
res += (s+32);
else
res += s;
}
return res;
}
};