根据ASCII规则 遇到大写字母就加32就好了
class Solution {
public:
string toLowerCase(string str) {
for( int i = 0 ; i < str.length() ; i++ ){
if( str[i] >= 'A' && str[i] <= 'Z' ) str[i] += 32;
}
return str;
}
};
根据ASCII规则 遇到大写字母就加32就好了
class Solution {
public:
string toLowerCase(string str) {
for( int i = 0 ; i < str.length() ; i++ ){
if( str[i] >= 'A' && str[i] <= 'Z' ) str[i] += 32;
}
return str;
}
};