#include<iostream> #include<string> #include<stdio.h> #include<vector> using namespace std; char samo[]={'a','i','e','u','y','o'}; string s; vector<int> v; int czysamo(char z){ for(int i=0; i<6;i++){ if(z==samo[i]){ return -1; } } return 0; } int load(){ char znak; for(int i=0;i<s.size();i++) { v.push_back(czysamo(s[i])); //cout<<v[i]; } } int pol(){ int result=0; vector<int> tab; if(v.size()<3){ return 0; } for(int i=2;i<v.size();i++){ int tmp=v[i - 2] + v[i - 1] + v[i]; if (tmp== 0 || tmp==-3){ tab.push_back(i); //cout<<i<<endl; } } tab.push_back(v.size()); for(int i=0;i<tab.size()-1;i++){ result+=(tab[i]-1)*(tab[i+1]-tab[i]); } return result; } int main(void){ cin>>s; load(); cout<<pol(); 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 55 56 57 58 59 | #include<iostream> #include<string> #include<stdio.h> #include<vector> using namespace std; char samo[]={'a','i','e','u','y','o'}; string s; vector<int> v; int czysamo(char z){ for(int i=0; i<6;i++){ if(z==samo[i]){ return -1; } } return 0; } int load(){ char znak; for(int i=0;i<s.size();i++) { v.push_back(czysamo(s[i])); //cout<<v[i]; } } int pol(){ int result=0; vector<int> tab; if(v.size()<3){ return 0; } for(int i=2;i<v.size();i++){ int tmp=v[i - 2] + v[i - 1] + v[i]; if (tmp== 0 || tmp==-3){ tab.push_back(i); //cout<<i<<endl; } } tab.push_back(v.size()); for(int i=0;i<tab.size()-1;i++){ result+=(tab[i]-1)*(tab[i+1]-tab[i]); } return result; } int main(void){ cin>>s; load(); cout<<pol(); return 0; } |