#include <iostream>
using namespace std;
int isVowel(char c)
{
if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='y')
return 1;
return 0;
}
main()
{
long long int counter = 0;
long long int len = 1;
long long int lastDiff = 0;
long long int inRow = 0;
int lastChar = 0;
char in;
cin >> in;
lastChar = isVowel(in);
while (1)
{
cin >> in;
len++;
if (cin.eof()) {
cout << counter << endl;
return 0;
}
if (isVowel(in) == lastChar)
inRow++;
else
inRow = 0;
lastChar = isVowel(in);
if (inRow == 2) {
counter += len-2;
lastDiff = len;
}
else if (inRow > 2) {
counter += len-2;
lastDiff = len;
}
else
if (lastDiff > 0)
counter += lastDiff-2;
}
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 | #include <iostream> using namespace std; int isVowel(char c) { if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='y') return 1; return 0; } main() { long long int counter = 0; long long int len = 1; long long int lastDiff = 0; long long int inRow = 0; int lastChar = 0; char in; cin >> in; lastChar = isVowel(in); while (1) { cin >> in; len++; if (cin.eof()) { cout << counter << endl; return 0; } if (isVowel(in) == lastChar) inRow++; else inRow = 0; lastChar = isVowel(in); if (inRow == 2) { counter += len-2; lastDiff = len; } else if (inRow > 2) { counter += len-2; lastDiff = len; } else if (lastDiff > 0) counter += lastDiff-2; } return 0; } |
English