首页
IT
登录
6mi
u
盘
搜
搜 索
IT
插入排序
插入排序
xiaoxiao
2021-04-17
42
for(int i=1; i<10;i++) { temp = a[i]; int j = i; while((j>0)&&(a[j-1]>temp))//将大于temp的数值向后移 { a[j] = a[j-1]; j--; } a[j] = temp;//找到比temp小的数值 或是 j已经等于1,将temp插入 }
没有数据交换的过程,节省时间
每次将新加入的数据找到合适位置进行插入
转载请注明原文地址: https://ju.6miu.com/read-673460.html
技术
最新回复
(
0
)