📜  void InsertionSort(int * a, int n) { int i, j, x; for (i = 1; i < n; i++) { x = a[i]; j = 我 - 1;而 (j >= 0 && a[j] > x) { a[j + 1] = a[j]; j = j - 1; } a[j + 1] = x; } } - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:09.132000             🧑  作者: Mango

代码示例1
void InsertionSort(int * a, int n) {
  int i, j, x;
  for (i = 1; i < n; i++) {
    x = a[i];
    j = i - 1;
    while (j >= 0 && a[j] > x) {
      a[j + 1] = a[j];
      j = j - 1;
    }
    a[j + 1] = x;
  }
}