https://leetcode.com/problems/to-lower-case/
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) { string ans = ""; int len = str.length(); for(int i = 0; i < len; i ++) { if(str[i] >= 'A' && str[i] <= 'Z') ans += (str[i] + 32); else ans += str[i]; } return ans; } };
大写变小写(凑数题) 今天 Leetcode 写到 200 就不写了