#include <iostream> using namespace std; bool testVowel(char letter) { bool vowel = false; char array [6] = {'a', 'e', 'i', 'o', 'u', 'y'}; for (int i = 0; i < 6; i++){ if (letter == array[i]){ vowel = true; } } return vowel; } int main() { int quantity = 0; int firstletter = 0; string word; cin >> word; for (int i = 2; i < word.length(); i++){ firstletter = i - 2; if ((testVowel(word.at(i)) == testVowel(word.at(i - 1))) && (testVowel(word.at(i)) == testVowel(word.at(i - 2)))){ quantity ++; quantity += (word.length() - i - 1); if (i > 2 && (testVowel(word.at(i)) != testVowel(word.at(i - 3)))) quantity += (word.length() - i) * firstletter; } } 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 | #include <iostream> using namespace std; bool testVowel(char letter) { bool vowel = false; char array [6] = {'a', 'e', 'i', 'o', 'u', 'y'}; for (int i = 0; i < 6; i++){ if (letter == array[i]){ vowel = true; } } return vowel; } int main() { int quantity = 0; int firstletter = 0; string word; cin >> word; for (int i = 2; i < word.length(); i++){ firstletter = i - 2; if ((testVowel(word.at(i)) == testVowel(word.at(i - 1))) && (testVowel(word.at(i)) == testVowel(word.at(i - 2)))){ quantity ++; quantity += (word.length() - i - 1); if (i > 2 && (testVowel(word.at(i)) != testVowel(word.at(i - 3)))) quantity += (word.length() - i) * firstletter; } } cout << quantity; return 0; } |