题解 | 最大最小值
最大最小值
https://www.nowcoder.com/practice/051cbca4504d40f5b20bb891d83ec408
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(),b = sc.nextInt(),c = sc.nextInt();
int temp1 = a > b? a:b;
int X = temp1 > c? temp1:c;
int temp2 = a < b? a:b;
int Y = temp2 < c? temp2:c;
System.out.println( "The maximum number is :" + " " + X);
System.out.println( "The minimum number is :" + " " + Y);
}
}
查看14道真题和解析