您的位置:首页 > 理论基础 > 计算机网络

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

2017-08-13 09:17 429 查看
判读条件

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 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: