思路:
可以直接调用tolower()函数,也可以对其ASCII码进行操作
#include<iostream>
#include<cstring>
#include<cctype>
using namespace std;
class Solution
{
public:
string toLowerCase(string str)
{
string str1 = "";
// for(auto c:str)
// str1+= tolower(c);
for(auto c:str)
{
if(c>=65 && c<=90)
c = c+32;
str1+=c;
}
return str1;
}
};
int main()
{
string str = "Hello";
string str1 = "";
Solution s;
str1 = s.toLowerCase(str);
cout<<str1<<endl;
return 0;
}