题目链接:HDU1039
/* 题目大意:验证所设密码可否接受,要求满足以下三个条件: 1、必须包含元音 2、三个连续的字母不能同时为元音或者辅音 3、两个连续的字母不能相同,其中"ee"."oo"除外 */ #include <bits/stdc++.h> using namespace std; int main() { string s; while (cin >> s && s != "end") { int flag = 0; int p = s.size(); for (int i = 0; i<p; i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') flag = 1; } int flag1 = 0; for (int i = 2; i<p; i++) { if ((s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') && ((s[i-1] == 'a' || s[i-1] == 'e' || s[i-1] == 'i' || s[i-1] == 'o' || s[i-1] == 'u')) && (s[i-2] == 'a' || s[i-2] == 'e' || s[i-2] == 'i' || s[i-2] == 'o' || s[i-2] == 'u')) flag1 = 1; else if ((s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u') && ((s[i-1] != 'a' && s[i-1] != 'e' && s[i-1] != 'i' && s[i-1] != 'o' && s[i-1] != 'u')) && (s[i-2] != 'a' && s[i-2] != 'e' && s[i-2] != 'i' && s[i-2] != 'o' && s[i-2] != 'u')) flag1 = 1; } int flag2 = 0; for (int i = 1; i<p; i++) { if (s[i] == s[i-1] && (s[i] != 'e'&& s[i] != 'o')) flag2 = 1; } //cout << flag << flag1 <<flag2 <<endl; if (flag == 1 && flag1 == 0 && flag2 == 0) cout << "<" << s << ">" << " is acceptable." << endl; else cout << "<" << s << ">" << " is not acceptable." << endl; s = ""; } return 0; }