随即输入3个数,求最大值和最小值
随即输入3个数,求最大值和最小值
答案
import java.util.Scanner;
public class MaxMin {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int max = a;
if (b > max) max = b;
if (c > max) max = c;
int min = a;
if (b < min) min = b;
if (c < min) min = c;
System.out.println("最大值:" + max + ",最小值:" + min);
}
}