对三个数排序 Exercise06_05
1 import java.util.Scanner; 2 /** 3 * @author 冰樱梦 4 * 时间:2018年下半年 5 * 题目:对三个数排序 6 * 7 */ 8 public class Exercise06_05 { 9 public static void main(String[] args){ 10 Scanner input=new Scanner(System.in); 11 System.out.println("输入三个数"); 12 double num1=input.nextDouble(); 13 double num2=input.nextDouble(); 14 double num3=input.nextDouble(); 15 displaySortedNumbers(num1,num2,num3); 16 } 17 public static void displaySortedNumbers(double num1,double num2,double num3){ 18 if(num1>num2 && num1>num3 && num2>num3) System.out.println(num3+" "+num2+" "+num1); 19 else if(num1>num2 && num1>num3 && num2<num3) System.out.println(num2+" "+num3+" "+num1); 20 else if(num2>num1 && num2>num3 && num1>num3) System.out.println(num3+" "+num1+" "+num2); 21 else if(num2>num1 && num2>num3 && num1<num3) System.out.println(num2+" "+num3+" "+num2); 22 else if(num3>num1 && num3>num2 && num1>num2) System.out.println(num2+" "+num1+" "+num3); 23 else System.out.println(num1+" "+num2+" "+num3); 24 } 25 }