#include <string>
#include <iostream>
using namespace std;

class Solution {
public:
    string toLowerCase(string str)
    {
        if (str.empty())
        {
            return str;
        }

        for (auto it = str.begin(); it!= str.end(); ++it)
        {
            if (*it >= 'A' && *it <= 'Z')
            {
                *it = *it - 'A' + 'a';
            }
        }

        return str;
    }
};

int main()
{
    Solution sol;
    cout << sol.toLowerCase("Hello") << endl;
    cout << sol.toLowerCase("here") << endl;
    cout << sol.toLowerCase("LOVELY") << endl;
}

 

 

709.转换成小写字母

相关文章: