字符串水题,只要条件判全就能过。
代码如下:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
bool Judge_Vowel(char ch)
{
if(ch=='a'|| ch=='e' || ch=='i' ||
ch=='o' || ch=='u')
return true;
return false;
}
int main()
{
#ifdef test
freopen("sample.txt", "r", stdin);
#endif
char str[25];
while(scanf("%s", str))
{
if(!strcmp(str, "end"))
break;
bool flag_1=false, flag_2=true;
int len = strlen(str);
for(int i=0; i<len; i++)
{
if(Judge_Vowel(str[i]))
flag_1 = true;
if(i>=2 && Judge_Vowel(str[i-2])
&& Judge_Vowel(str[i-1])
&& Judge_Vowel(str[i]))
{
flag_2 = false;
break;
}
else if(i>=2 && !Judge_Vowel(str[i-2])
&& !Judge_Vowel(str[i-1])
&& !Judge_Vowel(str[i]))
{
flag_2 = false;
break;
}
if(i>0 && str[i]==str[i-1] && str[i]!='e' && str[i]!='o')
{
flag_2 = false;
break;
}
}
if(flag_1 && flag_2)
printf("<%s> is acceptable.\n", str);
else
printf("<%s> is not acceptable.\n", str);
}
return 0;
}