#include <iostream> bool is_vovel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { std::string str; std::cin >> str; size_t add; bool found = false; size_t result = 0; for (size_t i = 2; i < str.size(); ++i) { if (is_vovel(str[i - 2]) == is_vovel(str[i - 1]) && is_vovel(str[i - 2]) == is_vovel(str[i])) { add = i - 1; found = true; } if (found) { result += add; } } std::cout << result << "\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | #include <iostream> bool is_vovel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { std::string str; std::cin >> str; size_t add; bool found = false; size_t result = 0; for (size_t i = 2; i < str.size(); ++i) { if (is_vovel(str[i - 2]) == is_vovel(str[i - 1]) && is_vovel(str[i - 2]) == is_vovel(str[i])) { add = i - 1; found = true; } if (found) { result += add; } } std::cout << result << "\n"; } |