728x90
반응형
#include <iostream>
using namespace std;
bool test1(string s);//모음 포함하고 있는지 판별
bool test2(string s);//모음 자음 세개 연속으로 오는지 판별
bool test3(string s);//같은 글자가 두번 연속으로 오는지 판별 ee와 oo는 허용
int main() {
string s;
while(1){
cin >> s;
if(s == "end") break;
if(test1(s) == true) cout << "yes1" << endl;
if(test2(s) == true) cout << "yes2" << endl;
if(test3(s) == true) cout << "yes3" << endl;
}
return 0;
}
bool test1(string s){
if(s.find('a') != string::npos) return true;
else if(s.find('e') != string::npos) return true;
else if(s.find('i') != string::npos) return true;
else if(s.find('o') != string::npos) return true;
else if(s.find('u') != string::npos) return true;
return false;
}
bool test2(string s){
int m=0,j=0;
for(int i = 0 ; i < s.length() ; i++){
if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u'){
if(j != 0) j = 0;
m++;
}
else {
if(m != 0) m = 0;
j++;
}
if(m >= 3 || j >= 3) return false;
}
return true;
}
bool test3(string s){
char c,tmp;
c = s[0];
for(int i=1 ; i<s.length() ; i++){
tmp = s[i];
if(tmp == 'e' || tmp == 'o') c = tmp;
else {
if(tmp == c) return false;
}
}
return true;
}
https://www.acmicpc.net/problem/4659
4659번: 비밀번호 발음하기
좋은 패스워드를 만드는것은 어려운 일이다. 대부분의 사용자들은 buddy처럼 발음하기 좋고 기억하기 쉬운 패스워드를 원하나, 이런 패스워드들은 보안의 문제가 발생한다. 어떤 사이트들은 xvtp
www.acmicpc.net
728x90
반응형
'Problem Solving' 카테고리의 다른 글
2-3. Longest Common Prefix (LeetCode 14) (0) | 2021.07.07 |
---|---|
2-2. OX퀴즈 (백준 8958) (0) | 2021.07.07 |
1-10. 농구 경기 (백준 1159) (0) | 2021.07.07 |
1-9. Two City Scheduling (LeetCode 1029) (0) | 2021.07.07 |
1-8. 소수 만들기 (프로그래머스 Summer/Winter coding 2018) (0) | 2021.07.07 |
댓글