#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); string slowo; long long last_num=0; cin>>slowo; long long num=0; long long com=0; long long cam=0; long long r; r=slowo.size(); for(long long i=0; i<r; ++i) { if(slowo[i]=='a' || slowo[i]=='u' || slowo[i]=='i' || slowo[i]=='o' || slowo[i]=='e' || slowo[i]=='y') { cam=0; ++com; if(com==3) { com=2; num+=(i-1-last_num)*(r-i); last_num=i-1; } } else { com=0; ++cam; if(cam==3) { cam=2; num+=(i-1-last_num)*(r-i); last_num=i-1; } } } cout<<num; }
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 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); string slowo; long long last_num=0; cin>>slowo; long long num=0; long long com=0; long long cam=0; long long r; r=slowo.size(); for(long long i=0; i<r; ++i) { if(slowo[i]=='a' || slowo[i]=='u' || slowo[i]=='i' || slowo[i]=='o' || slowo[i]=='e' || slowo[i]=='y') { cam=0; ++com; if(com==3) { com=2; num+=(i-1-last_num)*(r-i); last_num=i-1; } } else { com=0; ++cam; if(cam==3) { cam=2; num+=(i-1-last_num)*(r-i); last_num=i-1; } } } cout<<num; } |