#include <iostream>
#include <vector>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
string tekst;
cin >> tekst;
vector<bool> A;
vector<int> B;
B.push_back(0);
int dlg=tekst.size();
if(tekst[0]=='a'||tekst[0]=='e'||tekst[0]=='i'||tekst[0]=='o'||tekst[0]=='u'||tekst[0]=='y')
A.push_back(1);
else
A.push_back(0);
if(tekst[1]=='a'||tekst[1]=='e'||tekst[1]=='i'||tekst[1]=='o'||tekst[1]=='u'||tekst[1]=='y')
A.push_back(1);
else
A.push_back(0);
int suma=0;
for(int i=2;i<dlg;i++)
{
if(tekst[i]=='a'||tekst[i]=='e'||tekst[i]=='i'||tekst[i]=='o'||tekst[i]=='u'||tekst[i]=='y')
A.push_back(1);
else
A.push_back(0);
suma=A[i]+A[i-1]+A[i-2];
if(suma==0||suma==3)
{
B.push_back(i-1);
}
}
B.push_back(tekst.size()-1);
int wynik=0;
for(int i=1;i<B.size()-1;i++)
{
wynik+=(B[i])*(B[i+1]-B[i]);
}
cout << wynik;
}
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 | #include <iostream> #include <vector> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); string tekst; cin >> tekst; vector<bool> A; vector<int> B; B.push_back(0); int dlg=tekst.size(); if(tekst[0]=='a'||tekst[0]=='e'||tekst[0]=='i'||tekst[0]=='o'||tekst[0]=='u'||tekst[0]=='y') A.push_back(1); else A.push_back(0); if(tekst[1]=='a'||tekst[1]=='e'||tekst[1]=='i'||tekst[1]=='o'||tekst[1]=='u'||tekst[1]=='y') A.push_back(1); else A.push_back(0); int suma=0; for(int i=2;i<dlg;i++) { if(tekst[i]=='a'||tekst[i]=='e'||tekst[i]=='i'||tekst[i]=='o'||tekst[i]=='u'||tekst[i]=='y') A.push_back(1); else A.push_back(0); suma=A[i]+A[i-1]+A[i-2]; if(suma==0||suma==3) { B.push_back(i-1); } } B.push_back(tekst.size()-1); int wynik=0; for(int i=1;i<B.size()-1;i++) { wynik+=(B[i])*(B[i+1]-B[i]); } cout << wynik; } |
English