#include <bits/stdc++.h> using namespace std; string s; int n, samo[305]; long long res; bool typ(int i) { return samo[s[i]]; } int main() { ios_base::sync_with_stdio(0); cin >> s; samo['a'] = samo['e'] = samo['i'] = samo['o'] = samo['u'] = samo['y'] = 1; n = s.size(); int last = -1; for(int i = 2; i < n; i++)// koniec podslowa { if(typ(i) == typ(i - 1) && typ(i) == typ(i - 2)) last = i - 1; res += max(0, last); } cout << res; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <bits/stdc++.h> using namespace std; string s; int n, samo[305]; long long res; bool typ(int i) { return samo[s[i]]; } int main() { ios_base::sync_with_stdio(0); cin >> s; samo['a'] = samo['e'] = samo['i'] = samo['o'] = samo['u'] = samo['y'] = 1; n = s.size(); int last = -1; for(int i = 2; i < n; i++)// koniec podslowa { if(typ(i) == typ(i - 1) && typ(i) == typ(i - 2)) last = i - 1; res += max(0, last); } cout << res; } |