#include <iostream> #include <string> using namespace std; bool isInRange(char a){ switch(a){ case 'a': return true; break; case 'e': return true; break; case 'i': return true; break; case 'o': return true; break; case 'u': return true; break; case 'y': return true; break; } return false; } int main(){ string a; int index[400]; int indexer = 0, quantity = 0; cin >> a; // int leng = a.length(); bool hasTrio = false; for(int i = 0; i < leng - 2; i++){ if((isInRange(a[i]) && isInRange(a[i+1]) && isInRange(a[i+2])) || (!isInRange(a[i]) && !isInRange(a[i+1]) && !isInRange(a[i+2]))){ index[indexer++] = i; } } for(int i = 0; i < indexer; i++){ for(int j = index[i]; j >= 0; j--){ for(int b = (3 + (index[i] - j)); b <= leng - j; b++){ if(b == leng) continue; quantity++; } } } if(indexer > 0) quantity++; cout << quantity; 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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #include <iostream> #include <string> using namespace std; bool isInRange(char a){ switch(a){ case 'a': return true; break; case 'e': return true; break; case 'i': return true; break; case 'o': return true; break; case 'u': return true; break; case 'y': return true; break; } return false; } int main(){ string a; int index[400]; int indexer = 0, quantity = 0; cin >> a; // int leng = a.length(); bool hasTrio = false; for(int i = 0; i < leng - 2; i++){ if((isInRange(a[i]) && isInRange(a[i+1]) && isInRange(a[i+2])) || (!isInRange(a[i]) && !isInRange(a[i+1]) && !isInRange(a[i+2]))){ index[indexer++] = i; } } for(int i = 0; i < indexer; i++){ for(int j = index[i]; j >= 0; j--){ for(int b = (3 + (index[i] - j)); b <= leng - j; b++){ if(b == leng) continue; quantity++; } } } if(indexer > 0) quantity++; cout << quantity; return 0; } |