#include <iostream> using namespace std; bool sam[255]; long long res; int last=-1; string s; int main () { sam['a'] = sam['e'] = sam['i'] = sam['o'] = sam['u'] = sam['y'] = true; cin >> s; for (int i=2; i<s.size(); i++) { if ((sam[s[i]] && sam[s[i-1]] && sam[s[i-2]]) || (!sam[s[i]] && !sam[s[i-1]] && !sam[s[i-2]])) { last = i; } if (last != -1) { res += (last - 1); } } cout << res << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <iostream> using namespace std; bool sam[255]; long long res; int last=-1; string s; int main () { sam['a'] = sam['e'] = sam['i'] = sam['o'] = sam['u'] = sam['y'] = true; cin >> s; for (int i=2; i<s.size(); i++) { if ((sam[s[i]] && sam[s[i-1]] && sam[s[i-2]]) || (!sam[s[i]] && !sam[s[i-1]] && !sam[s[i-2]])) { last = i; } if (last != -1) { res += (last - 1); } } cout << res << endl; } |