public class xuanzepaixu {
public static void xuanzesort(int[] a){
int temp;
for(int i=0;i<a.length-1;i++){
for(int j=i;j<a.length-1;j++){
if(a[i]>a[j+1]){
temp=a[i];
a[i]=a[j+1];
a[j+1]=temp;
}
}
System.out.println("第"+(i+1)+"次排序结果:");
for(int ii=0;ii<a.length;ii++){
System.out.print(a[ii]+" ");
}
System.out.println();
}
System.out.println("排序后的数组为:");
for(int i=0;i<a.length;i++){
System.out.print(a[i]+" ");
}
}
public static void main(String[] args){
int[] array=new int[]{1,23,14,6,28,45,87,11,98};
System.out.println("排序前的数组为:");
for(int i=0;i<array.length;i++){
System.out.print(array[i]+" ");
}
System.out.println();
xuanzesort(array);
}
}
public static void xuanzesort(int[] a){
int temp;
for(int i=0;i<a.length-1;i++){
for(int j=i;j<a.length-1;j++){
if(a[i]>a[j+1]){
temp=a[i];
a[i]=a[j+1];
a[j+1]=temp;
}
}
System.out.println("第"+(i+1)+"次排序结果:");
for(int ii=0;ii<a.length;ii++){
System.out.print(a[ii]+" ");
}
System.out.println();
}
System.out.println("排序后的数组为:");
for(int i=0;i<a.length;i++){
System.out.print(a[i]+" ");
}
}
public static void main(String[] args){
int[] array=new int[]{1,23,14,6,28,45,87,11,98};
System.out.println("排序前的数组为:");
for(int i=0;i<array.length;i++){
System.out.print(array[i]+" ");
}
System.out.println();
xuanzesort(array);
}
}