zoukankan      html  css  js  c++  java
  • Leetcode709.To Lower Case转换成小写字母

    实现函数 ToLowerCase(),该函数接收一个字符串参数 str,并将该字符串中的大写字母转换成小写字母,之后返回新的字符串。

    示例 1:

    输入: "Hello" 输出: "hello"

    示例 2:

    输入: "here" 输出: "here"

    示例 3:

    输入: "LOVELY" 输出: "lovely"

    class Solution {
    public:
        string toLowerCase(string str) {
            int len = str.size();
            if(len == 0)
                return str;
            for(int i = 0; i < len; i++)
            {
                if(str[i] >= 'A' && str[i] <= 'Z')
                {
                    str[i] = 'a' + str[i] - 'A';
                }
            }
            return str;
        }
    };
  • 相关阅读:
    E. You Are Given Some Strings...
    神奇函数
    AC自动机再加强版
    AC自动机2
    AC自动机
    three arrays
    permutation 2
    string matching
    permutation 1
    equation
  • 原文地址:https://www.cnblogs.com/lMonster81/p/10433995.html
Copyright © 2011-2022 走看看