首页
IT
登录
6mi
u
盘
搜
搜 索
IT
直接插入排序
直接插入排序
xiaoxiao
2021-03-25
145
直接插入排序算法的时间复杂度为o(n*n)
void InsertSort(int *a,int Length) { int i,j; for(i =1;i<Length;i++) { if(a[i]<a[i-1]) { int temp = a[i]; for(j = i-1;j>=0&&temp>a[j];j--) a[j+1] = a[j]; a[j+1] = temp; } } }
转载请注明原文地址: https://ju.6miu.com/read-4507.html
技术
最新回复
(
0
)