#include<cstdio> //#include <stdbool.h> char c; char samo[6] = {'a','e','u','i','o','y'}; int samo_count = 6; bool isSamo = false; bool wasSamo = false; int current = 0; int i = 0; int ending = 0; int total = 0; int lenght = 0; int main() { while(scanf("%c", &c) != EOF && c >= 'a' and c <= 'z') { //printf("char:%c|\n", c); wasSamo = isSamo; isSamo = false; lenght = lenght + 1; for(i = 0; i < samo_count; i++) { if(samo[i] == c) isSamo = true; } if(wasSamo == isSamo) { current = current + 1; } else { current = 1; } if(current >= 3) { if(ending == 0) { ending = ending + lenght - 2; } else { ending = ending + 1; } } total = total + ending; //printf("current: %d\n", current); //printf("ending: %d\n", ending); } printf("%d", total); }
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 | #include<cstdio> //#include <stdbool.h> char c; char samo[6] = {'a','e','u','i','o','y'}; int samo_count = 6; bool isSamo = false; bool wasSamo = false; int current = 0; int i = 0; int ending = 0; int total = 0; int lenght = 0; int main() { while(scanf("%c", &c) != EOF && c >= 'a' and c <= 'z') { //printf("char:%c|\n", c); wasSamo = isSamo; isSamo = false; lenght = lenght + 1; for(i = 0; i < samo_count; i++) { if(samo[i] == c) isSamo = true; } if(wasSamo == isSamo) { current = current + 1; } else { current = 1; } if(current >= 3) { if(ending == 0) { ending = ending + lenght - 2; } else { ending = ending + 1; } } total = total + ending; //printf("current: %d\n", current); //printf("ending: %d\n", ending); } printf("%d", total); } |