Hdu 1039 字符串
本来以为是正则,结果只是字符串水题
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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream>
int main(){ //freopen("in.txt","r",stdin); char str[22];
char vowel[26]="aeiou"; char consonants[26]="bcdfghjklmnpqrstvwxyz";
while(scanf("%s",str) && strcmp(str,"end")){ int tag[3]; tag[0] = 0; int len = strlen(str); for(int i = 0;i < len;i++){ for(int j = 0;j < 5;j++){ if(str[i] == vowel[j]){ tag[0] = 1; break; } } }
//char ch[3]; //ch[0] = str[0]; tag[1] = 1; int flag[3] = {1,1,1}; for(int i = 0;i < len-2;i++){ flag[0] = 0; for(int j = 0;j < 21;j++){ if(str[i] == consonants[j]) flag[0] = 1; } flag[1] = 0; for(int j = 0;j < 21;j++){ if(str[i+1] == consonants[j]) flag[1] = 1; } flag[2] = 0; for(int j = 0;j < 21;j++){ if(str[i+2] == consonants[j]) flag[2] = 1; } if(flag[0] == 1 && flag [1] == 1 && flag[2] == 1) tag[1] = 0; }
for(int i = 0;i < len-2;i++){ flag[0] = 0; for(int j = 0;j < 5;j++){ if(str[i] == vowel[j]) flag[0] = 1; } flag[1] = 0; for(int j = 0;j < 5;j++){ if(str[i+1] == vowel[j]) flag[1] = 1; } flag[2] = 0; for(int j = 0;j < 5;j++){ if(str[i+2] == vowel[j]) flag[2] = 1; } if(flag[0] == 1 && flag [1] == 1 && flag[2] == 1) tag[1] = 0; }
//char ch = str[0]; tag[2] = 1; for(int i = 1;i < len;i++){ if(str[i-1] == str[i]) if(str[i] != 'e' && str[i] != 'o') tag[2] = 0; //ch = str[i]; } if(tag[0] == 1 && tag[1] == 1 && tag[2] == 1) printf("<%s> is acceptable.\n",str); else printf("<%s> is not acceptable.\n",str); } return 0; }
|
最后更新时间:
欢迎评论~
v1.5.2