标签:
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 char b[5]={‘a‘,‘e‘,‘i‘,‘o‘,‘u‘},c[21]={‘b‘,‘c‘,‘d‘,‘f‘,‘g‘,‘h‘,‘j‘,‘k‘,‘l‘,‘m‘,‘n‘,‘p‘,‘q‘,‘r‘,‘s‘,‘t‘,‘v‘,‘w‘,‘x‘,‘y‘,‘z‘}; 6 char d[]={‘a‘,‘i‘,‘u‘,‘b‘,‘c‘,‘d‘,‘f‘,‘g‘,‘h‘,‘j‘,‘k‘,‘l‘,‘m‘,‘n‘,‘p‘,‘q‘,‘r‘,‘s‘,‘t‘,‘v‘,‘w‘,‘x‘,‘y‘,‘z‘}; 7 char a[21]; 8 int len; 9 int vowels() 10 { 11 int i,k,j; 12 int flag; 13 for(i=0;i<len-2;i++) 14 { 15 flag=0; 16 for(j=0;j<3;j++) 17 { 18 for(k=0;k<5;k++) 19 { 20 if(a[i+j]==b[k]) 21 { 22 flag++; 23 break; 24 } 25 } 26 } 27 if(flag==3) 28 return 0; 29 } 30 return 1; 31 } 32 int consonants() 33 { 34 int i,k,j; 35 int flag; 36 for(i=0;i<len-2;i++) 37 { 38 flag=0; 39 for(j=0;j<3;j++) 40 { 41 for(k=0;k<21;k++) 42 { 43 if(a[i+j]==c[k]) 44 { 45 flag++; 46 break; 47 } 48 } 49 } 50 if(flag==3) 51 return 0; 52 } 53 return 1; 54 } 55 int consecutive_occurrences() 56 { 57 int i,j,k; 58 bool flag; 59 for(i=0;i<len-1;i++) 60 { 61 flag=0; 62 if(a[i]==a[i+1]) 63 { 64 for(j=0;j<24;j++) 65 if(a[i]==d[j]) 66 { 67 flag=1; 68 break; 69 } 70 } 71 if(flag) 72 return 0; 73 } 74 return 1; 75 } 76 int main() 77 { 78 char b[4]="end"; 79 while(cin>>a) 80 { 81 getchar(); 82 if(strcmp(a,b)==0) 83 break; 84 len=strlen(a); 85 int k=0; 86 if((strchr(a,‘a‘)!=NULL)||(strchr(a,‘e‘)!=NULL)||(strchr(a,‘i‘)!=NULL)||(strchr(a,‘o‘)!=NULL)||(strchr(a,‘u‘)!=NULL)) 87 k++; 88 if(vowels()&&consonants()) 89 k++; 90 if(consecutive_occurrences ()) 91 k++; 92 if(k==3) 93 cout<<‘<‘<<a<<‘>‘<<" is acceptable."<<endl; 94 else 95 cout<<‘<‘<<a<<‘>‘<<" is not acceptable."<<endl; 96 memset(a,0,sizeof(a)); 97 } 98 }
标签:
原文地址:http://www.cnblogs.com/a1225234/p/4545285.html