• 杭电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 }
  • 相关阅读:
    SQL函数union,union all整理
    Oracle中的having()函数
    SQL函数count(),sum()理解
    Office Online Server 和 SharePoint 2016配置时报错
    Manjaro 黑苹果网卡BCM4360折腾记
    Manjaro安装与基本配置
    在Arch Linux/Manjaro上安装KVM、QEMU和Virt Manager的方法
    Nginx 优化详解
    xargs 使用详解
    Centos7 搭建lnmp环境 (centos7+nginx+MySQL5.7.9+PHP7)
  • 原文地址:https://www.cnblogs.com/kb342/p/3671047.html
Copyright © 2020-2023  润新知