1.插入排序

 1 void InsertSort(int a[], int n)
 2 {
 3     int temp, i, j;
 4     for (i = 1; i < n; i++)
 5     {
 6         if (a[i] < a[i - 1])
 7         {
 8             temp = a[i];
 9             for (j = i - 1; j >= 0 && a[j]>temp; j--)
10                 a[j + 1] = a[j];
11             a[j + 1] = temp;
12         }
13     }
14 }
View Code

相关文章:

  • 2021-10-21
  • 2022-12-23
  • 2021-12-24
  • 2021-07-10
  • 2021-09-20
  • 2021-07-31
  • 2021-12-25
猜你喜欢
  • 2022-02-06
  • 2021-09-08
  • 2022-12-23
  • 2021-09-30
相关资源
相似解决方案