package _04_常见算法;

public class Test6 {
    public static void main(String[] args) {
        int[] arr = {3,2,11,8,1};
        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 ]){
                    int temp = arr[i];
                    arr[i] = arr[i+1];
                    arr[i+1] = temp;
                }
            }
        }
        // 遍历数组
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]  +" ");
        }
    }
}
