import java.util.Scanner;
public class test1 {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int[] a=new int[10];
for(int i=0;i<a.length;i++){
System.out.println("请输入"+a.length+"个数字,当前第"+(i+1)+"个:");
a[i]=sc.nextInt();
}
System.out.print("排序前数组: ");
for(int i:a){
System.out.print(i+"\t");
}
System.out.println();
new test1().f(a);
}
public void f(int[] a){
for(int i=a.length-1;i>0;i--){
for(int j=0;j<i;j++){
if(a[i]<a[j]){
int temp=a[i];;
a[i]=a[j];
a[j]=temp;
}
}
}
System.out.print("排序后的数组: ");
for(int i:a){
System.out.print(i+"\t");
}
}
}
温馨提示:内容为网友见解,仅供参考