package liu0913; import java.util.Scanner; public class Maopao { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("请输入第一个数"); int a=sc.nextInt(); System.out.println("请输入第二个数"); int b=sc.nextInt(); System.out.println("请输入第三个数"); int c=sc.nextInt(); System.out.println("请输入第四个数"); int d=sc.nextInt(); System.out.println("请输入第五个数"); int e=sc.nextInt(); int []array={a,b,c,d,e}; for(int i=0;i<(array.length-1);i++) { for(int j=i+1;j<array.length;j++) { if(array[i]>array[j]) { int zhong=array[i]; array[i]=array[j]; array[j]=zhong; } } } System.out.println("从下到大:"+array[0]+" "+array[1]+" "+array[2]+" "+array[3]+" "+array[4]); } }
时间: 2024-10-11 04:45:51