Dav*_*nco 11
这是一种没有提升的方法:
#include <string>
#include <algorithm>
#include <cctype>
#include <iostream>
char change_case (char c) {
if (std::isupper(c))
return std::tolower(c);
else
return std::toupper(c);
}
int main() {
std::string str;
str = "hEllo world";
std::transform(str.begin(), str.end(), str.begin(), change_case);
std::cout << str;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12605 次 |
| 最近记录: |