[水]ZOJ1698

来源:互联网 发布:淘宝网购物女装背心 编辑:程序博客网 时间:2024/05/01 10:17

给若干个单词,判断是否:

1.至少一个原音 

2.没有三个连续的原音和辅音 

3.除了ee和oo之外不能连续有相同的字字母

#include <bits/stdc++.h>using namespace std;string a;bool vowel(char ch){    if (ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')        return true;    return false;}bool Gao(){    bool vov=false;    for (int i=0;i<a.length();i++)    {        if (vowel(a[i]))            vov=true;    }    if (!vov)        return false;    int len=a.length();    for (int i=0;i<len-2;i++)    {        if (vowel(a[i])&&vowel(a[i+1])&&vowel(a[i+2]))            return false;         if (!vowel(a[i])&&!vowel(a[i+1])&&!vowel(a[i+2]))            return false;    }    for (int i=0;i<(len-1);i++)    {        if (a[i]==a[i+1]&&!(a[i]=='e'||a[i]=='o'))            return false;    }    return true;}int main(){    while (cin>>a)    {        if (a.length()==3 &&a=="end")            break;        if (Gao())            cout<<"<"<<a<<">"<<" is acceptable."<<endl;        else            cout<<"<"<<a<<">"<<" is not acceptable."<<endl;    }    return 0;}


0 0
原创粉丝点击