Use the keyboard to enter three numbers and display them in descending order.
The numbers displayed must be separated by spaces.
requirement:
The program should read these numbers from the keyboard.
The program should display numbers on the screen.
The program should display three numbers separated by spaces.
The program should display numbers in descending order.
package zh.codegym.task.task04.task0420;
/*
对三个数字进行排序
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
//在此编写你的代码
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String num2 = reader.readLine();
String num3 = reader.readLine();
String num4 = reader.readLine();
int A = Integer.parseInt(num2);
int B = Integer.parseInt(num3);
int C = Integer.parseInt(num4);
int [] array = new int[]{A,C,B};
int large = array[0];
int middle =array[1];
int small =array[2];
for(int x=0;x<array.length;x++){
if(array[x]>large){
large = array[x];
}
}
for(int x=0;x<array.length;x++){
if(array[x]<small){
small = array[x];
}
}
for(int x=0;x<array.length;x++){
if(array[x]<large&&array[x]>small){
middle= array[x];
}
}
System.out.println(large+" "+middle+" "+small);
}
}