Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
原文链接:https://leetcode.com/problems/to-lower-case/
水。。。
class Solution {
public:
string toLowerCase(string str) {
for(int i=0; i < str.size(); i++) {
if(str[i] >= 65 && str[i] <= 90) {
cout << str[i] << endl;
str[i] += 32;
}
}
return str;
}
};
本文介绍了一种将字符串转换为小写的实现方法,通过遍历字符串中的每个字符,检查其是否为大写字母,如果是,则将其转换为小写。

4714

被折叠的 条评论
为什么被折叠?



