publicclassTest04{ publicstaticvoidmain(String[] args){ Scanner scanner = new Scanner(System.in); System.out.println("第一只老虎的体重(kg):"); int a = scanner.nextInt(); System.out.println("第二只老虎的体重(kg):"); int b = scanner.nextInt();
// if (a == b) { // System.out.println("它俩一样重!"); // } else { // System.out.println("它俩不一样重!"); // }
System.out.println(a == b ? "体重相等" : "体重不相等"); } }
publicclassTest05{ publicstaticvoidmain(String[] args){ Scanner scanner = new Scanner(System.in);
System.out.println("第一个和尚多高(cm)?请输入:"); int a = scanner.nextInt();
System.out.println("第二个和尚多高(cm)?请输入:"); int b = scanner.nextInt();
System.out.println("第三个和尚多高(cm)?请输入:"); int c = scanner.nextInt(); // int temp = a > b ? a : b; // int max = temp > c ? temp : c; int max = a > b ? (a > c ? a : c) : (b > c ? b : c);