[c++]代码库
#include<iostream>//代码有些地方还不够简洁
#include<string>
#include <iomanip>
using namespace std;
bool is_vowel(char ch){
if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'){
return true;
}else{
return false;
}
}
int main(){
string s1;
bool flag;
int flag1;
int count;
while(cin>>s1 && s1 != "end"){//处理每行
count = 1;
flag1 = 1;
flag = is_vowel(s1[0]);
int i = 1;
for( ; i < s1.length(); i++){//处理每个字符
if(is_vowel(s1[i - 1]) == is_vowel(s1[i])){
count++;
}else{
if(count >= 3){
cout<<"<"<<s1<<">"<<" is not acceptable."<<endl;
flag1 = 0;
count = 1;
break;
}else{
flag = !flag;//flag == true表示元音字母
count = 1;
}
}
}
if(count >= 3){
cout<<"<"<<s1<<">"<<" is not acceptable."<<endl;
count = 1;
continue;
}
int j;
for(j = 0; j < s1.length(); j++){
if(is_vowel(s1[j])){
j--;
break;
}
}
int flag2 = 0;
for(int k = 0; k < s1.length() - 1; k++){
if(s1[k] == s1[k + 1] && s1[k] != 'e' && s1[k] != 'o'){
cout<<"<"<<s1<<">"<<" is not acceptable."<<endl;
flag2 = 1;
break;
}
}
if(flag2 == 1){
continue;
}
if(flag1){
if(j == s1.length()){
cout<<"<"<<s1<<">"<<" is not acceptable."<<endl;
continue;
}else{
cout<<"<"<<s1<<">"<<" is acceptable."<<endl;
continue;
}
}
}
}