import java.util.*;
public class mao{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.println("请输入成员个数:");
int i = in.nextInt();
int[] a = new int[i];
for(int j=0 ; j<a.length ; j++){
System.out.println("请输入数组元素:");
a[j] = in.nextInt();
}
System.out.println("数组元素原始顺序:");
for(int j=0 ; j<a.length ; j++){
System.out.print("\t"+a[j]);
}
System.out.println("\n数组元素由小到大排列为:");
for(int d=0 ; d < a.length-1 ; d++){
for(int c=d+1 ; c < a.length ; c++){
if(a[d] > a[c]){
int temp = a[c];
a[c]=a[d];
a[d]=temp;
}
}
}
for(int t=0 ; t<a.length ; t++){
System.out.print("\t"+a[t]);
}
}
}
转载于:https://my.oschina.net/RiceLee/blog/619166