#include <iostream> using namespace std; int w=0,d,l=-1; string z; int main() { cin>>z; d=z.length(); for(int i=0;i<d; i++) { if((z[i]=='a'||z[i]=='o'||z[i]=='u'||z[i]=='e'||z[i]=='y'||z[i]=='i')&&(z[i+1]=='a'||z[i+1]=='o'||z[i+1]=='u'||z[i+1]=='e'||z[i+1]=='y'||z[i+1]=='i')&&(z[i+2]=='a'||z[i+2]=='o'||z[i+2]=='u'||z[i+2]=='e'||z[i+2]=='y'||z[i+2]=='i')||(z[i]>97&&z[i]<123&&z[i]!='o'&&z[i]!='u'&&z[i]!='i'&&z[i]!='e'&&z[i]!='y')&&(z[i+1]>97&&z[i+1]<123&&z[i+1]!='o'&&z[i+1]!='u'&&z[i+1]!='i'&&z[i+1]!='e'&&z[i+1]!='y')&&(z[i+2]>97&&z[i+2]<123&&z[i+2]!='o'&&z[i+2]!='u'&&z[i+2]!='i'&&z[i+2]!='e'&&z[i+2]!='y')) { w++; if((d-i)<=3) { l++; i=l; d=z.length(); } else { i=l; d--; } } else if(i+1==d||(d-i)<=3) { if((d-i)<=3) { l++; i=l; d=z.length(); } else { i=l; d--; } } } 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 31 32 33 34 35 36 37 38 39 40 41 42 43 | #include <iostream> using namespace std; int w=0,d,l=-1; string z; int main() { cin>>z; d=z.length(); for(int i=0;i<d; i++) { if((z[i]=='a'||z[i]=='o'||z[i]=='u'||z[i]=='e'||z[i]=='y'||z[i]=='i')&&(z[i+1]=='a'||z[i+1]=='o'||z[i+1]=='u'||z[i+1]=='e'||z[i+1]=='y'||z[i+1]=='i')&&(z[i+2]=='a'||z[i+2]=='o'||z[i+2]=='u'||z[i+2]=='e'||z[i+2]=='y'||z[i+2]=='i')||(z[i]>97&&z[i]<123&&z[i]!='o'&&z[i]!='u'&&z[i]!='i'&&z[i]!='e'&&z[i]!='y')&&(z[i+1]>97&&z[i+1]<123&&z[i+1]!='o'&&z[i+1]!='u'&&z[i+1]!='i'&&z[i+1]!='e'&&z[i+1]!='y')&&(z[i+2]>97&&z[i+2]<123&&z[i+2]!='o'&&z[i+2]!='u'&&z[i+2]!='i'&&z[i+2]!='e'&&z[i+2]!='y')) { w++; if((d-i)<=3) { l++; i=l; d=z.length(); } else { i=l; d--; } } else if(i+1==d||(d-i)<=3) { if((d-i)<=3) { l++; i=l; d=z.length(); } else { i=l; d--; } } } cout<<w; return 0; } |