#include<iostream> using namespace std; int t[300], n, l; string s; long long ans; int main(){ ios_base::sync_with_stdio(0); t['a'] = t['e'] = t['o'] = t['u'] = t['y'] = t['i'] = 1; cin >> s; n = s.size(); for(int i = 2; i < n; i++){ if(t[s[i]] == t[s[i - 1]] && t[s[i - 1]] == t[s[i - 2]]){ l = i + 1; } ans += max(l - 2, 0); } cout << ans; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include<iostream> using namespace std; int t[300], n, l; string s; long long ans; int main(){ ios_base::sync_with_stdio(0); t['a'] = t['e'] = t['o'] = t['u'] = t['y'] = t['i'] = 1; cin >> s; n = s.size(); for(int i = 2; i < n; i++){ if(t[s[i]] == t[s[i - 1]] && t[s[i - 1]] == t[s[i - 2]]){ l = i + 1; } ans += max(l - 2, 0); } cout << ans; } |