#include <iostream> #include <string> using namespace std; bool isVow(char c) { if (c == 'a' | c == 'e' | c == 'i' | c == 'o' | c == 'u' | c == 'y') return true; return false; } int main() { int words = 0; int counter = 0; short triple = 0; int lastBegin = -1; bool isLastVow = false; string s; cin >> s; for (counter; counter<s.length(); counter++) { if (isLastVow == isVow(s[counter])) { triple++; if (triple == 3) { words += (counter - 2 - lastBegin)*(s.length() - counter); lastBegin = counter - 2; triple--; } } else { triple = 1; isLastVow = isVow(s[counter]); } } cout << words; }
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 | #include <iostream> #include <string> using namespace std; bool isVow(char c) { if (c == 'a' | c == 'e' | c == 'i' | c == 'o' | c == 'u' | c == 'y') return true; return false; } int main() { int words = 0; int counter = 0; short triple = 0; int lastBegin = -1; bool isLastVow = false; string s; cin >> s; for (counter; counter<s.length(); counter++) { if (isLastVow == isVow(s[counter])) { triple++; if (triple == 3) { words += (counter - 2 - lastBegin)*(s.length() - counter); lastBegin = counter - 2; triple--; } } else { triple = 1; isLastVow = isVow(s[counter]); } } cout << words; } |