码迷,mamicode.com
首页 > 其他好文 > 详细

leetcode 709. To Lower Case

时间:2019-09-17 22:45:55      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:pre   ring   int   out   span   leetcode   for   sam   solution   

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

标签:pre   ring   int   out   span   leetcode   for   sam   solution   

原文地址:https://www.cnblogs.com/qinduanyinghua/p/11537342.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!