#include <iostream> #include <string> #include <vector> #include <sstream> using namespace std; int main() { string line; int count=0; getline(cin, line); vector<string> tokens; string word; istringstream iss(line, istringstream::in); while( iss >> word ) { int pa=0; int pz=0; for(int i=0;i<word.length();i++){ switch(word[i]){ case 'a': pa++;pz=0; break; case 'e': pa++;pz=0; break; case 'i': pa++;pz=0; break; case 'o': pa++;pz=0; break; case 'u': pa++;pz=0; break; case 'y': pa++;pz=0; break; default: pa=0;pz++; break; } if(pa==3 || pz==3){ if(pa==3){ int counta=0; for(int j=0;j<word.length();j++){ switch(word[j]){ case 'a': counta++; break; case 'e': counta++; break; case 'i': counta++; break; case 'o': counta++; break; case 'u': counta++; break; case 'y': counta++; break; default: break; } } if(counta==word.length()){ count+=(word.length()-3); } } if(pz==3){ int counta=0; for(int j=0;j<word.length();j++){ switch(word[j]){ case 'a': break; case 'e': break; case 'i': break; case 'o': break; case 'u': break; case 'y': break; default: counta++; break; } } if(counta==word.length()){ count+=(word.length()-3); } } count+=(word.length()-3)*2; pa=0;pz=0; } } cout << count << endl; } }
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #include <iostream> #include <string> #include <vector> #include <sstream> using namespace std; int main() { string line; int count=0; getline(cin, line); vector<string> tokens; string word; istringstream iss(line, istringstream::in); while( iss >> word ) { int pa=0; int pz=0; for(int i=0;i<word.length();i++){ switch(word[i]){ case 'a': pa++;pz=0; break; case 'e': pa++;pz=0; break; case 'i': pa++;pz=0; break; case 'o': pa++;pz=0; break; case 'u': pa++;pz=0; break; case 'y': pa++;pz=0; break; default: pa=0;pz++; break; } if(pa==3 || pz==3){ if(pa==3){ int counta=0; for(int j=0;j<word.length();j++){ switch(word[j]){ case 'a': counta++; break; case 'e': counta++; break; case 'i': counta++; break; case 'o': counta++; break; case 'u': counta++; break; case 'y': counta++; break; default: break; } } if(counta==word.length()){ count+=(word.length()-3); } } if(pz==3){ int counta=0; for(int j=0;j<word.length();j++){ switch(word[j]){ case 'a': break; case 'e': break; case 'i': break; case 'o': break; case 'u': break; case 'y': break; default: counta++; break; } } if(counta==word.length()){ count+=(word.length()-3); } } count+=(word.length()-3)*2; pa=0;pz=0; } } cout << count << endl; } } |