#include<bits/stdc++.h> using namespace std; bool czySamogloska(char c) { return c == 'a' || c == 'e' || c == 'o' || c == 'u' || c == 'y' || c == 'i'; } int main() { ios::sync_with_stdio(0); string napis; cin >> napis; long long letters[napis.length()]; bool flag = false; for(int i = 0; i < napis.length(); i++) { if(czySamogloska(napis[i])) { letters[i] = 1; } else letters[i] = 0; } long long j = 1; long long wynik = 0; for(int i = 0; i < napis.length()-2; i++) { if((letters[i] == 1 && letters[i+1] == 1 && letters[i+2] == 1) || (letters[i] == 0 && letters[i+1] == 0 && letters[i+2] == 0)) { if(!flag) { wynik += (i+j)*(napis.length()-i-2); j = i; flag = true; } else { wynik += (i-j)*(napis.length()-i-2); j=i; } } } cout << wynik << endl; }
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 | #include<bits/stdc++.h> using namespace std; bool czySamogloska(char c) { return c == 'a' || c == 'e' || c == 'o' || c == 'u' || c == 'y' || c == 'i'; } int main() { ios::sync_with_stdio(0); string napis; cin >> napis; long long letters[napis.length()]; bool flag = false; for(int i = 0; i < napis.length(); i++) { if(czySamogloska(napis[i])) { letters[i] = 1; } else letters[i] = 0; } long long j = 1; long long wynik = 0; for(int i = 0; i < napis.length()-2; i++) { if((letters[i] == 1 && letters[i+1] == 1 && letters[i+2] == 1) || (letters[i] == 0 && letters[i+1] == 0 && letters[i+2] == 0)) { if(!flag) { wynik += (i+j)*(napis.length()-i-2); j = i; flag = true; } else { wynik += (i-j)*(napis.length()-i-2); j=i; } } } cout << wynik << endl; } |