Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
109093 汤奕硕 元音字母转换 C++ Accepted 1 MS 272 KB 877 2025-01-26 16:24:40

Tests(1/1):


Code:

#include <iostream> #include <string> #include <cctype> // 用于字符操作 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 s; getline(cin, s); // 读取字符串 // 遍历字符串并进行转换 for (char &c : s) { if (isVowel(c)) { c = toupper(c); // 元音字母转为大写 } else { c = tolower(c); // 其余字母转为小写 } } cout << s << endl; // 输出结果 } return 0; }