//我也是新手,说一下新手分享,做多层嵌套,我习惯从里层开始网外层写,这样自己容易明白
public class demo13 {
public static void main(String[] args) {int[] arr = {3,4,11,16,8,1,9,10};
maopao(arr);
for(int i=0;i<arr.length;i++){
System.out.print(arr[i]+"\t");
}
}
public static void maopao(int[] arr){
for(int j=0;j<arr.length-1;j++)
for(int i=0;i<arr.length-1-j;i++){
if(arr[i]<arr[i+1]){
exchange(arr,i,i+1);
}
}
}
public static void exchange(int[] arr,int index1,int index2){
int temp=0;
temp=arr[index1];
arr[index1]=arr[index2];
arr[index2]=temp;
}
}