#include #include <unordered_set>

using namespace std;

int main() { int n; string s; unordered_set vowels = {'a', 'e', 'i', 'o', 'u'};

cin >> n >> s;

for (int i = 0; i < n; i++) {
    if (vowels.count(s[i])) { // 如果当前字符是元音
        cout << s[i]; // 输出该元音
        while (i < n - 1 && vowels.count(s[i + 1])) { // 将相邻的元音删掉
            i++;
        }
    } else { // 如果不是元音
        cout << s[i]; // 直接输出
    }
}

return 0;

}

C++ 字符串处理:删除相邻元音

原文地址: https://www.cveoy.top/t/topic/m51i 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录