You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
370 B

#include <stdio.h>
//直接插入排序
void insertSort(int arr[], int n) {
int i, j, temp;
for (i = 1; i < n; i++) {
if (arr[i] < arr[i - 1]) {
temp = arr[i];
for (j = i - 1; j >= 0 && arr[j] > temp; --j) {
arr[j + 1] = arr[j];
}
arr[j + 1] = temp;
}
}
printf("Over\n");
}