java冒泡排序

  • Post author:
  • Post category:java




java冒泡排序

public class Main {
    public static void main(String[] args) {
        int[] arr = {12, 4, 24, 11, 32, 1, 312};
        int temp, j, i;
        for (j = 0; j < arr.length - 1; j++) {
            for (i = 0; i < arr.length - 1 - j; i++) {
                if (arr[i] > arr[i + 1]) {
                    temp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = temp;
                }
            }
        }
    }
}



版权声明:本文为m0_51953797原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。