[leetcode]709. To Lower Case

[leetcode]709. To Lower Case


Analysis

年纪大了就会比较惜命~—— [ummmm~]

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

Implement

class Solution {
public:
    string toLowerCase(string str) {
        string res = "";
        for(auto s:str){
            if(s>='A' && s<='Z'){
               s = s-('Z'-'z');
                res += s;
            }
            else
                res += s;
        }
        return res;
    }
};

猜你喜欢

转载自blog.csdn.net/weixin_32135877/article/details/81169997