HDU 1039 Easier Done Than Said?

 

 

求简单好记的密码

没什么难度,上代码

 

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 using namespace std;
 5 struct Pas{
 6     int a;
 7     char c;
 8 }p[25];
 9 
10 int main()
11 {
12     int flag,num;
13     char c[25];
14     while(~scanf("%s",c),strcmp(c,"end")){
15         num=0;flag=1;//密码初始为不好记,有韵母才变为0
16         for(int i=0;i<strlen(c);i++){
17             p[i].c=c[i];
18             if(c[i]=='a'||c[i]=='e'||c[i]=='o'||c[i]=='i'||c[i]=='u'){
19                 p[i].a=1;
20                 flag=0;
21             }
22             else{
23                 p[i].a=-1;
24             }
25             num=0;//每次统计要清零
26             if(i>=2){
27                 for(int j=0;j<3;j++){
28                     num+=p[i-j].a;
29                 }
30             }
31             if(i!=0&&p[i].c==p[i-1].c&&c[i]!='o'&&c[i]!='e'){
32                 flag=1;break;
33             }
34 
35             if(num >=3 ||num<=-3){
36                 flag=1;break;
37             }
38         }
39         if(flag == 1)
40             printf("<%s> is not acceptable.\n",c);
41         else
42             printf("<%s> is acceptable.\n",c);
43     }
44     return 0;
45 }

 

posted @ 2016-01-24 12:14  闪耀子  阅读(148)  评论(0编辑  收藏  举报