#include <bits/stdc++.h> using namespace std; const int MAXN = 2e5+69; bool is(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } char s[MAXN]; int l; int main() { scanf("%s", s+1); size_t len = 1, wyn = 0;; while (s[len]) { // const char &c = s[len]; // printf("znak %c %d\n", c, is(c)); if (len >= 3 && is(s[len]) == is(s[len-1]) && is(s[len-1]) == is(s[len-2])) { l = len-2; } // printf("w %lu jest +%d == %lu\n", len, l, wyn); wyn += l; len++; } cout << wyn << endl; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <bits/stdc++.h> using namespace std; const int MAXN = 2e5+69; bool is(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y'; } char s[MAXN]; int l; int main() { scanf("%s", s+1); size_t len = 1, wyn = 0;; while (s[len]) { // const char &c = s[len]; // printf("znak %c %d\n", c, is(c)); if (len >= 3 && is(s[len]) == is(s[len-1]) && is(s[len-1]) == is(s[len-2])) { l = len-2; } // printf("w %lu jest +%d == %lu\n", len, l, wyn); wyn += l; len++; } cout << wyn << endl; } |