Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16543 Accepted Submission(s): 7846
FnordCom is developing such a password generator. You work in the quality control department, and it's your job to test the generator and make sure that the passwords are acceptable. To be acceptable, a password must satisfy these three rules:
It must contain at least one vowel.
It cannot contain three consecutive vowels or three consecutive consonants.
It cannot contain two consecutive occurrences of the same letter, except for 'ee' or 'oo'.
(For the purposes of this problem, the vowels are 'a', 'e', 'i', 'o', and 'u'; all other letters are consonants.) Note that these rules are not perfect; there are many common/pronounceable words that are not acceptable.
代码:
1 #include<stdio.h> 2 #include<string.h> 3 int main(){ 4 char a[100]; 5 int i,num,flag,len; 6 int b[100]; 7 while(~scanf("%s",&a)&&strcmp("end",a)){ 8 for(i=0;i<100;i++) 9 b[i]=0; 10 num=0; 11 flag=1; 12 len=strlen(a); 13 for(i=0;i<len;i++){ 14 if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u'){ 15 b[i]=1; 16 num+=1; 17 } 18 else 19 b[i]=2; 20 } 21 for(i=2;i<len;i++){ 22 if(b[i]==b[i-1]&&b[i-1]==b[i-2]){ 23 flag=0; 24 break; 25 } 26 } 27 for(i=1;i<len;i++){ 28 if(a[i]==a[i-1]&&a[i]!='e'&&a[i]!='o'){ 29 flag=0; 30 break; 31 } 32 } 33 if(num==0||flag==0) 34 printf("<%s> is not acceptable.\n",a); 35 else 36 printf("<%s> is acceptable.\n",a); 37 } 38 return 0; 39 }