#include <iostream> #include <string> using namespace std; int main() { int count = 0; char c; long long howMany = 0, sam = 0, spo = 0, e = -1, i =0; std::string line; std::getline(std::cin, line); for (i = 0; i < line.length(); i++) { c = line[i]; if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { sam++; spo = 0; } else { spo++; sam = 0; } if (spo + sam > 2) { howMany += (i - 1);e = i; } else if (e != -1)howMany += (e - 1); } cout << howMany; 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 | #include <iostream> #include <string> using namespace std; int main() { int count = 0; char c; long long howMany = 0, sam = 0, spo = 0, e = -1, i =0; std::string line; std::getline(std::cin, line); for (i = 0; i < line.length(); i++) { c = line[i]; if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y') { sam++; spo = 0; } else { spo++; sam = 0; } if (spo + sam > 2) { howMany += (i - 1);e = i; } else if (e != -1)howMany += (e - 1); } cout << howMany; return 0; } |