#include<bits/stdc++.h> using namespace std; int main() { string x; cin>>x; int d=x.size(),i; int s[d]; for (i=0;i<d;i++) { if (x[i]=='a' || x[i]=='e' || x[i]=='i' || x[i]=='o' || x[i]=='u' || x[i]=='y') s[i]=1; else s[i]=0; // cout<<s[i]<<" "; } long long w=0; int a=s[0],b=s[1],og=0; for (i=2;i<d;i++) { if (a==b && a==s[i]) {w+=(i-og-1)*(d-i); og=i-1;} a=b; b=s[i]; //cout<<w<<" "; } cout<<w; 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 | #include<bits/stdc++.h> using namespace std; int main() { string x; cin>>x; int d=x.size(),i; int s[d]; for (i=0;i<d;i++) { if (x[i]=='a' || x[i]=='e' || x[i]=='i' || x[i]=='o' || x[i]=='u' || x[i]=='y') s[i]=1; else s[i]=0; // cout<<s[i]<<" "; } long long w=0; int a=s[0],b=s[1],og=0; for (i=2;i<d;i++) { if (a==b && a==s[i]) {w+=(i-og-1)*(d-i); og=i-1;} a=b; b=s[i]; //cout<<w<<" "; } cout<<w; return 0; } |