hdu 1039 Easier Done Than Said? (DP)
ps: 题目要求,给你一个字符串,要求:
1:至少有1个元音字母
2:不能有3个或以上连续的元音字母或,其他非元音字母一起
3:不能有连续的两个字符相同,“ee”和“oo”除外
#include<stdio.h> #include<string.h> int main() { char s[1000]=""; int len; int a,b,c; int i; gets(s); int counta,countb; while(strcmp(s,"end")) { a=0; b=1; c=1; counta=0; countb=0; len=strlen(s); for(i=0;i<len;i++) { if((s[i]=='a')||(s[i]=='e')||(s[i]=='i')||(s[i]=='o')||(s[i]=='u')) { a=1; counta++; countb=0; } else { countb++; counta=0; } if(counta==3||countb==3) { b=0; break; } if(s[i]==s[i+1]&&s[i]!='e'&&s[i]!='o') { c=0; break; } } if(a==1&&c==1&&b==1&&len<=20&&len>=1) { printf("<%s> is acceptable.\n",s); } else printf("<%s> is not acceptable.\n",s); gets(s); } return 0; }