收藏 分享(赏)

直接插入排序代码.doc

上传人:jinchen 文档编号:7348621 上传时间:2019-05-15 格式:DOC 页数:1 大小:11.50KB
下载 相关 举报
直接插入排序代码.doc_第1页
第1页 / 共1页
亲,该文档总共1页,全部预览完了,如果喜欢就下载吧!
资源描述

#includeusing namespace std;/直接插入排序void insert_sort(int a,int n)int i,j,temp;for(i=1;i=0 j-)/如果满足条件就往后挪,最坏的情况是 temp 比 a0小,它要放在最前面aj+1=aj;aj+1=temp;/找到下标为 i 的数的放置位置void print_arry(int a, int len)for(int i=0;ilen;i+)/循环打印数组的每个元素coutai“;coutendl;int main()int a=7,8,3,4,6,9,5,1,2;cout“before insert sort: “;print_arry(a,9);insert_sort(a,9);/进行直接插入排序cout“afert insert sort: “;print_arry(a,9);return 0;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报