编写一个程序,将输入字符串中的小写字母转换成大写字母后进行输出。对于字符串中的非小写字母,不做任何转换操作。 输入格式:…
- User
编写一个程序,将输入字符串中的小写字母转换成大写字母后进行输出。对于字符串中的非小写字母,不做任何转换操作。
输入格式: 输入一个字符串,该字符串可以包含大写字母、小写字母、数字和其它字符(如空格),但不包含换行回车符。
输出格式: 将输入字符串中的小写字母转换为大写字母,而非小写字母保持不变。输出转换后的字符串。
- Assistant
def convert_lowercase(input_str): output_str = '' for char in input_str: if char.islower(): output_str += char.upper() else: output_str += char return output_str
input_str = input() output_str = convert_lowercase(input_str) print(output_str)
- User
用c加加的语言编写一个程序,将输入字符串中的小写字母转换成大写字母后进行输出。对于字符串中的非小写字母,不做任何转换操作。
输入格式: 输入一个字符串,该字符串可以包含大写字母、小写字母、数字和其它字符(如空格),但不包含换行回车符。
输出格式: 将输入字符串中的小写字母转换为大写字母,而非小写字母保持不变。输出转换后的字符串。
- Assistant
#include <stdio.h> #include <ctype.h>
int main() { char input_str[100]; fgets(input_str, sizeof(input_str), stdin);
for (int i = 0; input_str[i] != '\0'; i++) { if (islower(input_str[i])) { input_str[i] = toupper(input_str[i]); } } printf("%s", input_str); return 0;}
- User
用c加加的语言编写一个程序,将输入字符串中的小写字母转换成大写字母后进行输出。对于字符串中的非小写字母,不做任何转换操作。
输入格式: 输入一个字符串,该字符串可以包含大写字母、小写字母、数字和其它字符(如空格),但不包含换行回车符。
输出格式: 将输入字符串中的小写字母转换为大写字母,而非小写字母保持不变。输出转换后的字符串。
- Assistant
#include #include #include using namespace std;
int main() { string input_str; getline(cin, input_str);
for (int i = 0; i < input_str.length(); i++) { if (islower(input_str[i])) { input_str[i] = toupper(input_str[i]); } } cout << input_str; return 0;}