int[] a = new int[]{9, 2, 4, 5, 6, 55, 99, 110, 180, 166, 177, 195, 186, 200, 11, 18}; for (int i = 0; i < a.length; i++) { int temp = a[i]; int j; for (j = i - 1; j >= 0; j--) { if (a[j] > temp) { a[j + 1] = a[j]; } else { break; } } a[j + 1] = temp; } for ( int num :a){ Log.e("min",num+""); }
插入排序
最新推荐文章于 2022-03-21 17:50:50 发布