#include <iostream> #include <string> using namespace std; bool isvowel(char c) { if((c == 'a') || (c == 'e') || (c == 'y') || (c == 'u') || (c == 'i') || (c == 'o')) return 1; return 0; } int main() { ios::sync_with_stdio(false); cin.tie(0); string s; long long r = 0, i, j, x; cin >> s; for(i = 0; i < (s.size()-1); i++) { for(j = (i+1); j < s.size(); j++) { for(x = i; x < (j-1); x++) { if((isvowel(s[x]) && isvowel(s[x+1]) && isvowel(s[x+2])) || (!isvowel(s[x]) && !isvowel(s[x+1]) && !isvowel(s[x+2]))) { r++; break; } } } } cout << r; return 0; }
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 | #include <iostream> #include <string> using namespace std; bool isvowel(char c) { if((c == 'a') || (c == 'e') || (c == 'y') || (c == 'u') || (c == 'i') || (c == 'o')) return 1; return 0; } int main() { ios::sync_with_stdio(false); cin.tie(0); string s; long long r = 0, i, j, x; cin >> s; for(i = 0; i < (s.size()-1); i++) { for(j = (i+1); j < s.size(); j++) { for(x = i; x < (j-1); x++) { if((isvowel(s[x]) && isvowel(s[x+1]) && isvowel(s[x+2])) || (!isvowel(s[x]) && !isvowel(s[x+1]) && !isvowel(s[x+2]))) { r++; break; } } } } cout << r; return 0; } |