LeetCode题解之To Lower Case

1、题目描述

2、分析

遍历字符串,使用C++ 的 标准库函数 isalpha() 判断字符是否为 字母,然后对其做 tolower() .

3、代码

 1 string toLowerCase(string str) {
 2         if( str.empty() ) return str;
 3         
 4         for( string::iterator it = str.begin() ; it != str.end() ; ++it ){
 5             if( isalpha(*it) ){
 6                 *it = tolower( *it );
 7             }
 8         }
 9         return str;
10         
11     }
pp
原文地址:https://www.cnblogs.com/wangxiaoyong/p/9300239.html