#include <iostream> using namespace std; int main() { string a; cin>>a; int l=0,d=a.length(); unsigned long long w=0; bool p1, p2, p3; if(a[0]=='a'||a[0]=='e'||a[0]=='i'||a[0]=='o'||a[0]=='u'||a[0]=='y'){ p3=true; }else{ p3=false; } if(a[1]=='a'||a[1]=='e'||a[1]=='i'||a[1]=='o'||a[1]=='u'||a[1]=='y'){ p2=true; }else{ p2=false; } for(int i=2; i<d; ++i){ if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='y'){ p1=true; }else{ p1=false; } if(p3==p2&&p3==p1){ w+=(i-1-l)*(d-i); l=i-1; } p3=p2; p2=p1; } cout<<w; }
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 | #include <iostream> using namespace std; int main() { string a; cin>>a; int l=0,d=a.length(); unsigned long long w=0; bool p1, p2, p3; if(a[0]=='a'||a[0]=='e'||a[0]=='i'||a[0]=='o'||a[0]=='u'||a[0]=='y'){ p3=true; }else{ p3=false; } if(a[1]=='a'||a[1]=='e'||a[1]=='i'||a[1]=='o'||a[1]=='u'||a[1]=='y'){ p2=true; }else{ p2=false; } for(int i=2; i<d; ++i){ if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'||a[i]=='y'){ p1=true; }else{ p1=false; } if(p3==p2&&p3==p1){ w+=(i-1-l)*(d-i); l=i-1; } p3=p2; p2=p1; } cout<<w; } |