// Example program #include <iostream> #include <string> bool iss(char& c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { unsigned long count = 0; unsigned long kn = 0; int sc = 0, nc = 0; int l = 0; std::string input; getline (std::cin, input); for (int i = 0; i < input.length(); i++) { auto c = input[i]; if (iss(c)) { sc++; nc = 0; } else { sc = 0; nc++; } if (sc > 2) { kn = kn + i - l - 1; l = i - 1; } else if(nc > 2) { kn = kn + i - l - 1; l = i - 1; } count += kn; } std::cout << count; }
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | // Example program #include <iostream> #include <string> bool iss(char& c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } int main() { unsigned long count = 0; unsigned long kn = 0; int sc = 0, nc = 0; int l = 0; std::string input; getline (std::cin, input); for (int i = 0; i < input.length(); i++) { auto c = input[i]; if (iss(c)) { sc++; nc = 0; } else { sc = 0; nc++; } if (sc > 2) { kn = kn + i - l - 1; l = i - 1; } else if(nc > 2) { kn = kn + i - l - 1; l = i - 1; } count += kn; } std::cout << count; } |