求三个数中的最值(代码):

public static void main(String[] args) {
int a = 4;
int b = 2;
int c = 3;
int max = 0;
int min = 0;
if (a > b && a > c){
max = a;
}
else if (b > a && b > c){
max = b;
}
else
max = c;
if (a < b && a < c) {
min = a;
}
else if (b < a && b < c) {
min = b;
}
else
min = c;
System.out.println("max = " + max);
System.out.println("min = " + min);
}

posted @ 2021-01-06 17:48  LinYanyan  阅读(161)  评论(0编辑  收藏  举报