C++ 字符串大小写转换算法详解
#include
int main() { string str; cin >> str;
for (int i = 0; i < str.length(); i++) {
if (str[i] >= 'a' && str[i] <= 'z') {
str[i] = toupper(str[i]);
} else if (str[i] >= 'A' && str[i] <= 'Z') {
str[i] = tolower(str[i]);
}
}
cout << str << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/pbGY 著作权归作者所有。请勿转载和采集!