#include <iostream> #include <vector> #include <string> using namespace std; vector<int> checkSp(string data) { vector<int> v; for(int i=0;i<data.length()-2;i++){ if(((data[(i)]!='a' && data[(i)]!='e' && data[(i)]!='i' && data[(i)]!='o' && data[(i)]!='u' && data[(i)]!='y') && (data[(i+1)]!='a' && data[(i+1)]!='e' && data[(i+1)]!='i' && data[(i+1)]!='o' && data[(i+1)]!='u' && data[(i+1)]!='y') && (data[(i+2)]!='a' && data[(i+2)]!='e' && data[(i+2)]!='i' && data[(i+2)]!='o' && data[(i+2)]!='u' && data[(i+2)]!='y')) || ((data[(i)]=='a' || data[(i)]=='e' || data[(i)]=='i' || data[(i)]=='o' || data[(i)]=='u' || data[(i)]=='y') && (data[(i+1)]=='a' || data[(i+1)]=='e' || data[(i+1)]=='i' || data[(i+1)]=='o' || data[(i+1)]=='u' || data[(i+1)]=='y') && (data[(i+2)]=='a' || data[(i+2)]=='e' || data[(i+2)]=='i' || data[(i+2)]=='o' || data[(i+2)]=='u' || data[(i+2)]=='y'))){ v.push_back(i); } } return v; } int main(){ ios_base::sync_with_stdio(0); string data; cin >> data; vector<int> listaSp = checkSp(data); long long wynik=0; for(int i=0;i<listaSp.size();i++){ if(i==0) wynik+=(listaSp[i]+1-i)*(data.length()-listaSp[i]-2); else{ wynik+=(listaSp[i]-listaSp[i-1])*(data.length()-listaSp[i]-2); } } cout << wynik << 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 | #include <iostream> #include <vector> #include <string> using namespace std; vector<int> checkSp(string data) { vector<int> v; for(int i=0;i<data.length()-2;i++){ if(((data[(i)]!='a' && data[(i)]!='e' && data[(i)]!='i' && data[(i)]!='o' && data[(i)]!='u' && data[(i)]!='y') && (data[(i+1)]!='a' && data[(i+1)]!='e' && data[(i+1)]!='i' && data[(i+1)]!='o' && data[(i+1)]!='u' && data[(i+1)]!='y') && (data[(i+2)]!='a' && data[(i+2)]!='e' && data[(i+2)]!='i' && data[(i+2)]!='o' && data[(i+2)]!='u' && data[(i+2)]!='y')) || ((data[(i)]=='a' || data[(i)]=='e' || data[(i)]=='i' || data[(i)]=='o' || data[(i)]=='u' || data[(i)]=='y') && (data[(i+1)]=='a' || data[(i+1)]=='e' || data[(i+1)]=='i' || data[(i+1)]=='o' || data[(i+1)]=='u' || data[(i+1)]=='y') && (data[(i+2)]=='a' || data[(i+2)]=='e' || data[(i+2)]=='i' || data[(i+2)]=='o' || data[(i+2)]=='u' || data[(i+2)]=='y'))){ v.push_back(i); } } return v; } int main(){ ios_base::sync_with_stdio(0); string data; cin >> data; vector<int> listaSp = checkSp(data); long long wynik=0; for(int i=0;i<listaSp.size();i++){ if(i==0) wynik+=(listaSp[i]+1-i)*(data.length()-listaSp[i]-2); else{ wynik+=(listaSp[i]-listaSp[i-1])*(data.length()-listaSp[i]-2); } } cout << wynik << endl; } |