#include <iostream> using namespace std; int main() { int n, i, l, count; long result = 0; char c; bool isA = true; bool samo = true; int lastl = -1; string str; cin >> str; l = 0; count = 0; for(std::string::size_type i = 0; i < str.size(); ++i) { c = str[i]; if(count==3) count=2; samo = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); if(samo != isA) count = 0; l++; count++; isA = samo; if(count==3){ if(lastl!=-1) result += (lastl + 1) * (l - lastl - 3); lastl=l-3; } } if(lastl!=-1) result += (lastl + 1) * (l - lastl - 2); cout << result; return 0; }
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 | #include <iostream> using namespace std; int main() { int n, i, l, count; long result = 0; char c; bool isA = true; bool samo = true; int lastl = -1; string str; cin >> str; l = 0; count = 0; for(std::string::size_type i = 0; i < str.size(); ++i) { c = str[i]; if(count==3) count=2; samo = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'); if(samo != isA) count = 0; l++; count++; isA = samo; if(count==3){ if(lastl!=-1) result += (lastl + 1) * (l - lastl - 3); lastl=l-3; } } if(lastl!=-1) result += (lastl + 1) * (l - lastl - 2); cout << result; return 0; } |