用JAVA输入三个数从大到小排列输出

2024-10-30 23:16:14
有1个网友回答
网友(1):

int a , b , c , max , middle , min ;
a = Integer.parseInt(args [0]);
b = Integer.parseInt(args [1]);
c = Integer.parseInt(args [2]);
max = a;
if(b > a && b > c ){
max = b;
}
if(c > a && c > b){
max = c;
}
min = a;
if(b < a && b < c){
min = b;
}
if(c < a && c < b){
min = c;
}
middle = (a + b + c) - (max + min);
System.out.println(min + ","+ middle + "," + max);