插入排序
2020-12-13 01:56
标签:class return 插入排序 insert sort nbsp ++ amp pre 插入排序 标签:class return 插入排序 insert sort nbsp ++ amp pre 原文地址:https://www.cnblogs.com/YUJIE666/p/11020523.html 1 int[] insertionSort(int arr[]) {//插入排序
2 int preIndex,current;
3 for(int i = 1; i ) {
4 preIndex = i - 1;
5 current = arr[i];
6 while (preIndex >= 0 && arr[preIndex] > current) {
7 arr[preIndex + 1] = arr[preIndex];
8 preIndex--;
9 }
10 arr[preIndex + 1] = current;
11 }
12 return arr;
13 }
上一篇:php global变量无效