http://acm.hdu.edu.cn/showproblem.php?pid=1039(水~)

Posted 有一天我们渺小的作为 或许 会巨大震动整个世界

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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.\n");
49         }
50         else printf("not acceptable.\n");
51     }
52     return 0;
53 }

 

以上是关于http://acm.hdu.edu.cn/showproblem.php?pid=1039(水~)的主要内容,如果未能解决你的问题,请参考以下文章