冒泡排序
package homework10;
import java.util.Arrays;
public class paixu {
public static void main(String[] args) {
int[] arr = new int[]{2,101,6,1,50,3,7,6,4,100,30,5,7,0,};
//冒泡排序,比相邻的元素
for(int i = 0;i<arr.length-1;i++){
for(int j =0;j< arr.length-1-i;j++){//每次排列次数-1
if(arr[j]>arr[j+1]){
int temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
}System.out.println(Arrays.toString(arr));
}
}