插入排序

来源:互联网 发布:无人机编队表演算法 编辑:程序博客网 时间:2024/06/11 05:27



* 直接插入排序 */void InsertSort(int *a, int len){int i,j;int temp;for (i=1; i<len; ++i)//每次表示待插入的元素{temp = a[i];for (j=i-1; j>=0; --j) //表示前面已排列有序的数据{if (a[j]>temp){a[j+1] = a[j];}else break;}a[j+1] = temp;}}


0 0
原创粉丝点击