import java.util.Scanner;
public class Main1039 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
String input = sc.nextLine();
boolean one = false; //第一步
boolean two = true;//第二步
boolean three = true;//第三步
//查看是否符合第一要求
for (int i = 0; i < input.length(); i++) {
if (yuanorfu(input.charAt(i))) {
one = true;
break;
}
}
//查看是否符合第二要求
for (int i = 2; i < input.length(); i++) {
if (yuanorfu(input.charAt(i - 2)) && yuanorfu(input.charAt(i - 1)) && yuanorfu(input.charAt(i))) {
two = false;
break;
} else {
if (!yuanorfu(input.charAt(i - 2)) && !yuanorfu(input.charAt(i - 1))
&& !yuanorfu(input.charAt(i))) {
two = false;
break;
}
}
}
//查看是否符合第三步要求
for (int i = 0; i < input.length() - 1; i++) {
if (input.charAt(i) == input.charAt(i + 1)) {
if (input.charAt(i) == 'e' || input.charAt(i) == 'o') {
continue;
} else {
three = false;
break;
}
}
}
//输出
if (one && two && three) {
System.out.println("<" + input + "> is acceptable.");
} else {
System.out.println("<" + input + "> is not acceptable.");
}
}
}
//是元音还是辅音
public static boolean yuanorfu(char name) {
if (name == 'a' || name == 'e' || name == 'i' || name == 'o' || name == 'u') {
return true;
} else
return false;
}
}
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1039
杭电ACM1039 java 总是错误,大神来帮帮小弟
答案:2 悬赏:40
解决时间 2021-12-30 10:40
- 提问者网友:王者刀枪不入
- 2021-12-30 03:19
最佳答案
- 二级知识专家网友:抱不住太阳的深海
- 2021-12-30 03:42
: )
仔细审题
The input consists of one or more potential passwords, one per line, followed by a line containing only the word 'end' that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters.
end不需要参加判断是否合法
仔细审题
The input consists of one or more potential passwords, one per line, followed by a line containing only the word 'end' that signals the end of the file. Each password is at least one and at most twenty letters long and consists only of lowercase letters.
end不需要参加判断是否合法
全部回答
- 1楼网友:两不相欠
- 2021-12-30 05:13
不明白啊 = =!
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯