leetcode 709. To Lower Case

Posted 琴影

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode 709. 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"

 

 1 class Solution {
 2 public:
 3     string toLowerCase(string str) {
 4         string res;
 5         for (int i = 0; i < str.length(); i++) {
 6             if (str[i] >= A && str[i] <= Z) {
 7                 res += a + (str[i] - A);
 8             } else {
 9                 res += str[i];
10             }
11         }
12         return res;
13     }
14 };

 

以上是关于leetcode 709. To Lower Case的主要内容,如果未能解决你的问题,请参考以下文章

Leetcode709. To Lower Case

leetcode 709. To Lower Case

LeetCode 709.To Lower Case

[LeetCode] 709. To Lower Case

[LeetCode]709. To Lower Case

LeetCode 709 To Lower Case 解题报告