zoukankan      html  css  js  c++  java
  • http://acm.hdu.edu.cn/showproblem.php?pid=1039(水~)

    判读条件

    1:有元音字母

    2:不能三个连续元音或辅音

    3.不能连续两个相同的字母,除非ee或oo

     1 #include<cstdio>
     2 #include<cstring>
     3 #include<algorithm>
     4 #include<string>
     5 using namespace std;
     6 char word[30];
     7 bool panyuan(int id){
     8     if(word[id]=='a'||word[id]=='e'||word[id]=='i'||word[id]=='o'||word[id]=='u') return true;
     9     return false;
    10 }
    11 bool test1(int n){
    12     for(int i = 0; i < n; i++){
    13         if(panyuan(i)) return true;
    14     }
    15     return false;
    16 }
    17 bool test2(int n){
    18     int yuan, fu;
    19     yuan = fu = 0;
    20     for(int i = 0; i < n; i++){
    21         if(panyuan(i)){
    22             yuan++; fu = 0;
    23         }
    24         else {
    25             fu++; yuan = 0;
    26         }
    27         if(fu>=3||yuan>=3) return false;
    28     }
    29     return true;
    30 }
    31 bool test3(int n){
    32     for(int i = 1; i < n; i++){
    33         if(word[i]==word[i-1]){
    34             if(word[i]=='e'||word[i]=='o') continue;
    35             else return false;
    36         }
    37     }
    38     return true;
    39 }
    40 int main()
    41 {
    42     while(~scanf("%s",word))
    43     {
    44         int len = strlen(word);
    45         if(len==3&&word[0]=='e'&&word[1]=='n'&&word[2]=='d') return 0;
    46         printf("<%s> is ",word);
    47         if(test1(len)&&test2(len)&&test3(len)) {
    48             printf("acceptable.
    ");
    49         }
    50         else printf("not acceptable.
    ");
    51     }
    52     return 0;
    53 }
  • 相关阅读:
    2019年春季学期第三周作业
    2019年春季学期第二周作业
    7-2 求最大值及其下标 (20 分)
    7-1 查找整数 (10 分)
    人生中最重要的三位老师
    自我介绍
    学期总结
    编程作业 抓老鼠啊~亏了还是赚了?
    作业——10
    作业——9
  • 原文地址:https://www.cnblogs.com/shanyr/p/7352435.html
Copyright © 2011-2022 走看看