public static void compIf() {
Scanner sc = new Scanner(System.in);//键盘录入三个数
int x = sc.nextInt();
int y = sc.nextInt();
int z = sc.nextInt();
if(x > y && x > z) {
System.out.println("最大值是:" + x);
} else if(y < z) { // 此时x>y,则x<z或x<y均可
System.out.println("最大值是:" + z);
} else {
System.out.println("最大值是:" + y);
}
} |
|