public class Paixu { public static void main(String[] args) { int[] arr = new int[]{9, 8, 7, 6, 5, 4, 3, 2, 1}; int[] arrs = ChaRu(arr); System.out.println(Arrays.toString(arrs)); } public static int[] ChaRu(int[] arr) { for (int i = 1; i < arr.length; i++) { int curr = arr[i]; int temp = i - 1; while (temp >= 0 && curr < arr[temp]) { arr[temp + 1] = arr[temp]; temp--; } arr[temp + 1] = curr; } return arr; } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)