#include <iostream> #include <string> using namespace std; bool samogloska(const char &c){ if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return true; return false; } int main(){ long long odp=0; int sam=0,spol=0,pocz=0; string a; cin >> a; for(unsigned int i=0;i<a.size();i++){ if(samogloska(a[i])){ sam++; spol=0; } else{ spol++; sam=0; } if(sam>=3||spol>=3)pocz=i-1; odp+=pocz; } cout<<odp<<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 | #include <iostream> #include <string> using namespace std; bool samogloska(const char &c){ if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='y')return true; return false; } int main(){ long long odp=0; int sam=0,spol=0,pocz=0; string a; cin >> a; for(unsigned int i=0;i<a.size();i++){ if(samogloska(a[i])){ sam++; spol=0; } else{ spol++; sam=0; } if(sam>=3||spol>=3)pocz=i-1; odp+=pocz; } cout<<odp<<endl; } |