字符串大小写转换:C++ 代码实现
#include <iostream>
#include <string>
using namespace std;
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/o79P 著作权归作者所有。请勿转载和采集!