#include <iostream> #include <string> bool sam(char a); using namespace std; int main() { string h; cin >> h; long long pokico = 0; int dlug = 1; int twojStary = 0; bool samo = false; if (sam(h[0])) { samo = true; } for (int i = 1; i < h.length(); i++) { if (sam(h[i]) == samo) { dlug++; } else { samo = !samo; dlug = 1; } if (dlug > 2) { if (twojStary) { pokico += (twojStary - 1) * (i - twojStary); } else { } twojStary = i; } } if (twojStary) { pokico += (twojStary - 1) * (h.length() - twojStary); } cout << pokico; } bool sam(char a) { if (a == 'y' || a == 'u' || a == 'o' || a == 'i' || a == 'e' || a == 'a') return true; return false; }
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 50 51 52 53 54 55 56 57 58 | #include <iostream> #include <string> bool sam(char a); using namespace std; int main() { string h; cin >> h; long long pokico = 0; int dlug = 1; int twojStary = 0; bool samo = false; if (sam(h[0])) { samo = true; } for (int i = 1; i < h.length(); i++) { if (sam(h[i]) == samo) { dlug++; } else { samo = !samo; dlug = 1; } if (dlug > 2) { if (twojStary) { pokico += (twojStary - 1) * (i - twojStary); } else { } twojStary = i; } } if (twojStary) { pokico += (twojStary - 1) * (h.length() - twojStary); } cout << pokico; } bool sam(char a) { if (a == 'y' || a == 'u' || a == 'o' || a == 'i' || a == 'e' || a == 'a') return true; return false; } |