【HDOJ】1039 Easier Done Than Said?
字符串简单题。
1 #include <stdio.h> 2 #include <string.h> 3 4 #define MAXNUM 25 5 #define isVOWEL(ch) (ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u') 6 7 char buf[MAXNUM]; 8 9 int main() { 10 int i, len, flg; 11 int vown, vow3n, con3n; 12 13 while (scanf("%s", buf) != EOF) { 14 if (strcmp(buf, "end") == 0) 15 break; 16 len = strlen(buf); 17 vown = vow3n = con3n = flg = 0; 18 for (i=0; i<len; ++i) { 19 if (isVOWEL(buf[i])) { 20 vown = 1; 21 vow3n++; 22 con3n = 0; 23 } else { 24 con3n++; 25 vow3n = 0; 26 } 27 if ( buf[i+1]==buf[i] && !(buf[i]=='e'||buf[i]=='o') ) 28 flg = 1; 29 if (flg || vow3n==3 || con3n==3) { 30 flg = 1; 31 break; 32 } 33 } 34 if (flg || !vown) 35 printf("<%s> is not acceptable.\n", buf); 36 else 37 printf("<%s> is acceptable.\n", buf); 38 } 39 40 return 0; 41 }