709. To Lower Case
作者:
美不胜收oo | 来源:发表于
2018-09-14 11:30 被阅读0次描述
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.
Example 1:
Input: "Hello"
Output: "hello"
Example 2:
Input: "here"
Output: "here"
Example 3:
Input: "LOVELY"
Output: "lovely"
代码
class Solution {
public:
string toLowerCase(string str) {
for(int i = 0;i<str.size();i++)
{
if(str[i]<='Z'&&str[i]>='A')
{
str[i] = str[i]-('A'-'a');
}
}
return str;
}
};
本文标题:709. To Lower Case
本文链接:https://www.haomeiwen.com/subject/daxogftx.html
网友评论