import java.util.Scanner;
public class test1 {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.print("Enter a:");
int a=input.nextInt();
System.out.print("Enter b:");
int b=input.nextInt();
System.out.print("Enter c:"); //输入三个数
int c=input.nextInt();
int max =0;
int mid=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;
}
if(a<b & a>c || a<c &a>c){mid=a;}else if(b<a & b>c || b>a & b<c){mid=b;}else{mid=c;} //列举出中间值情况
System.out.println(min+" "+mid+" "+max);
}
}
Java三个整数大小排序
最新推荐文章于 2024-11-04 22:26:34 发布