먼저 문자가 모음인지 자음인지 확인해줄 isVowol함수를 작성.
그리고 패스워드의 품질을 확인해줄 check함수를 작성했다.
여러 조건들을 잘 지지고 볶아서 위 두 함수를 잘 만들어주면 간단하다.
#include <bits/stdc++.h>
using namespace std;
string s;
int a,b,flag;
bool isVowel(char c){
if(c == 'a' | c == 'e' | c == 'i' | c == 'o' | c == 'u' )
return true;
else return false;
}
bool check(string s){
for(int i=0; i<s.size(); i++){
if(i > 0){
if(s[i-1] != 'e' && s[i-1] != 'o' && s[i-1] == s[i]){
return false;
}
}
if(isVowel(s[i])){ a++; b=0; flag=1;}
else { b++; a=0; }
if(a == 3 || b == 3){
return false;
}
}
if(flag) return true;
else return false;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
while(cin >> s){
if(s == "end") break;
a = 0; b = 0; flag = 0;
if(check(s)) cout<<"<"<<s<<"> is acceptable.\n";
else cout<<"<"<<s<<"> is not acceptable.\n";
}
return 0;
}