#include <iostream> #include <vector> bool fun(char a,char b,char c) { if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='y') { if((b=='a'||b=='e'||b=='i'||b=='o'||b=='u'||b=='y')&&(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')) { return true; } return false; } else { if((b=='a'||b=='e'||b=='i'||b=='o'||b=='u'||b=='y')||(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')) { return false; } return true; } } int main() { std::vector<char> list; char c; size_t counter=0,last=0; bool x= false; while((c=getchar())) { if(c=='\n') { break; } else { list.push_back(c); } } if(fun(list[0],list[1],list[2])){++counter;x= true;} for(size_t i=2;i+1<=list.size()-1;++i) { if(fun(list[i-1],list[i],list[i+1])) { last=i-1; x= true; } if(x) { counter+=last+1; } } std::cout << counter; 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 44 45 46 47 48 49 50 51 52 53 54 | #include <iostream> #include <vector> bool fun(char a,char b,char c) { if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='y') { if((b=='a'||b=='e'||b=='i'||b=='o'||b=='u'||b=='y')&&(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')) { return true; } return false; } else { if((b=='a'||b=='e'||b=='i'||b=='o'||b=='u'||b=='y')||(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')) { return false; } return true; } } int main() { std::vector<char> list; char c; size_t counter=0,last=0; bool x= false; while((c=getchar())) { if(c=='\n') { break; } else { list.push_back(c); } } if(fun(list[0],list[1],list[2])){++counter;x= true;} for(size_t i=2;i+1<=list.size()-1;++i) { if(fun(list[i-1],list[i],list[i+1])) { last=i-1; x= true; } if(x) { counter+=last+1; } } std::cout << counter; return 0; } |