描述给定一个字符串将其中所有的小写字母转换成大写字母。输入描述输入一行包含一个字符串长度不超过100可能包含空格。输出描述输出转换后的字符串。希望能用c++编写代码
#include <iostream>
#include <string>
#include <cctype>
int main() {
std::string str;
std::getline(std::cin, str);
for (char& c : str) {
if (std::islower(c)) {
c = std::toupper(c);
}
}
std::cout << str << std::endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/i2Jt 著作权归作者所有。请勿转载和采集!