public void compare(int x, int y, int z){
if(x < y){
if(x < z){
System.out.println(x);
if(y < z){
System.out.println(y);
System.out.println(z);
}else {
System.out.println(z);
System.out.println(y);
}
}else {
System.out.println(z);
System.out.println(x);
System.out.println(y);
}
}else {
if(y > z){
System.out.println(z);
System.out.println(y);
System.out.println(x);
}else {
System.out.println(y);
if(x < z){
System.out.println(x);
System.out.println(z);
}else {
System.out.println(z);
System.out.println(x);
}
}
}
}
1、
public static void main(String []args)
{
System.out.println("请输入三个整数:");
Scanner input=new Scanner(System.in);
int []num =new int[3];
num[0]=input.nextInt();
num[1]=input.nextInt();
num[2]=input.nextInt();
Arrays.sort(num);
for (int i = 0; i < num.length; i++) {
System.out.println(num[i]);
}
}
2、运行效果
不对啊,我显示有两处错误