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

时间:2023-03-08 18:55:09

判读条件

1:有元音字母

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

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

 #include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
char word[];
bool panyuan(int id){
if(word[id]=='a'||word[id]=='e'||word[id]=='i'||word[id]=='o'||word[id]=='u') return true;
return false;
}
bool test1(int n){
for(int i = ; i < n; i++){
if(panyuan(i)) return true;
}
return false;
}
bool test2(int n){
int yuan, fu;
yuan = fu = ;
for(int i = ; i < n; i++){
if(panyuan(i)){
yuan++; fu = ;
}
else {
fu++; yuan = ;
}
if(fu>=||yuan>=) return false;
}
return true;
}
bool test3(int n){
for(int i = ; i < n; i++){
if(word[i]==word[i-]){
if(word[i]=='e'||word[i]=='o') continue;
else return false;
}
}
return true;
}
int main()
{
while(~scanf("%s",word))
{
int len = strlen(word);
if(len==&&word[]=='e'&&word[]=='n'&&word[]=='d') return ;
printf("<%s> is ",word);
if(test1(len)&&test2(len)&&test3(len)) {
printf("acceptable.\n");
}
else printf("not acceptable.\n");
}
return ;
}