Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
113276 彭士宝 元音字母转换 C++ Accepted 1 MS 272 KB 982 2025-03-15 16:24:12

Tests(1/1):


Code:

#include <iostream> #include <string> #include <cctype> // 用于tolower和toupper函数 using namespace std; // 判断是否为元音字母 bool isVowel(char c) { c = tolower(c); // 转换为小写进行判断 return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'; } int main() { int T; cin >> T; // 读取测试数据的个数 cin.ignore(); // 忽略换行符,确保下一次读取时从第一个字符串开始 while (T--) { string str; getline(cin, str); // 读取每一行字符串 // 遍历字符串,根据条件转换字母 for (char &c : str) { if (isVowel(c)) { c = toupper(c); // 如果是元音字母,转换为大写 } else { c = tolower(c); // 如果不是元音字母,转换为小写 } } // 输出处理后的字符串 cout << str << endl; } return 0; }