杭电acm 1039题

这道题也比较简单,写三个函数判断三个条件即可.....

但是开始时我按照已经注释掉的提交,居然提示WA,我百思不得其解,后改成上面的判断式就可以了,求高手解答....

 1 #include "iostream"
 2 
 3 using namespace std;
 4 
 5 #define Max 21
 6 int Function1(char *p,int len);
 7 int Function2(char *p,int len);
 8 int Function3(char *p,int len);
 9 int vowel(char p);
10 int main(void)
11 {
12     char letters[Max];
13     int len;
14     int condition_1=0,condition_2=0,condition_3=0;
15     while(cin>>letters)
16     {
17         if(!strcmp(letters,"end"))
18             break;
19         len=strlen(letters);
20         condition_1=Function1(letters,len);
21         condition_2=Function2(letters,len);
22         condition_3=Function3(letters,len);
23         if(condition_1&&condition_2&&condition_3)
24             cout<<"<"<<letters<<">"<<" is acceptable."<<endl;
25         else 
26             cout<<"<"<<letters<<">"<<" is not acceptable."<<endl;
27     /*    if(condition_1==1)
28         {
29             condition_2=Function2(letters,len);
30             if(condition_2==1)
31             {
32                 condition_3=Function3(letters,len);
33                 if(condition_3==1)
34                     cout<<"<"<<letters<<">"<<" is acceptable."<<endl;
35                 else cout<<"<"<<letters<<">"<<" is not acceptable."<<endl;
36             }
37             else cout<<"<"<<letters<<">"<<" is not acceptable."<<endl;
38         }
39         else cout<<"<"<<letters<<">"<<" is not acceptable."<<endl;*/
40     }
41     return 0;
42 }
43 
44 
45 int Function1(char *p,int len)
46 {
47     for(int i=0;i<len;i++)
48     {
49         if(p[i]=='a'||p[i]=='e'||p[i]=='i'||p[i]=='o'||p[i]=='u')
50             return 1;
51     }
52     return 0;
53 }
54 int Function2(char *p,int len)
55 {
56     for(int i=0;i<len;i++)
57     {
58         if(((i+2)<len)&&(vowel(p[i]))&&(vowel(p[i+1]))&&(vowel(p[i+2])))
59             return 0;
60         else if(((i+2)<len)&&(!vowel(p[i]))&&(!vowel(p[i+1]))&&(!vowel(p[i+2])))
61             return 0;
62     }
63     return 1;
64 }
65 int Function3(char *p,int len)
66 {
67     char flag;
68     for(int i=0;i<len;i++)
69     {
70         flag=p[i];
71         if(((i+1)<len)&&(p[i+1]==flag)&&(flag!='e')&&(flag!='o'))
72             return 0;
73     }
74     return 1;
75 }
76 
77 int vowel(char p)
78 {
79     if(p=='a'||p=='e'||p=='i'||p=='o'||p=='u')
80         return 1;
81     else return 0;
82 }

 

转载于:https://www.cnblogs.com/kb342/p/3671047.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值