#include <iostream> using namespace std; bool czySamoGloska(char a){ if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u' || a=='y'){ return true; } return false; } int main(){ string a; cin >> a; long long start=0,end=a.size()-1; long long wynik=0; for(int i=1;i<a.size()-1;i++){ long long iloSamo = 0; if(czySamoGloska(a[i-1])){iloSamo++;} if(czySamoGloska(a[i])){iloSamo++;} if(czySamoGloska(a[i+1])){iloSamo++;} if(iloSamo==3 || iloSamo==0){ long long lewy = ((i-start+1+1)*(i-start+1))/2; long long prawy = ((end-i+1+1)*(end-i+1))/2; long long caly = (end-start+1+1)*(end-start+1)/2; wynik+=caly-lewy-prawy+1; start=i; } } cout << wynik; }
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 | #include <iostream> using namespace std; bool czySamoGloska(char a){ if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u' || a=='y'){ return true; } return false; } int main(){ string a; cin >> a; long long start=0,end=a.size()-1; long long wynik=0; for(int i=1;i<a.size()-1;i++){ long long iloSamo = 0; if(czySamoGloska(a[i-1])){iloSamo++;} if(czySamoGloska(a[i])){iloSamo++;} if(czySamoGloska(a[i+1])){iloSamo++;} if(iloSamo==3 || iloSamo==0){ long long lewy = ((i-start+1+1)*(i-start+1))/2; long long prawy = ((end-i+1+1)*(end-i+1))/2; long long caly = (end-start+1+1)*(end-start+1)/2; wynik+=caly-lewy-prawy+1; start=i; } } cout << wynik; } |