C++ 字符串大小写转换:将大写字母转换为小写字母
#include
using namespace std;
int main() { string s; cin >> s;
// 将大写字母转换为小写字母
for (int i = 0; i < s.length(); i++) {
if (s[i] >= 'A' && s[i] <= 'Z') {
s[i] = s[i] - 'A' + 'a';
}
}
cout << s << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/pYPu 著作权归作者所有。请勿转载和采集!