排序算法二:直接插入排序
2015-10-25 21:34
204 查看
static void InsertSort(int[] array) { for(int i = 1;i<array.Length;i++) { int index = 0;//index为将要插入的位置 while (index < i) { int temp = array[i];//temp为插入的值 if (array[index] < temp) { int j = i; while (j >= index && j > 0) { array[j] = array[j-1]; j--; } array[index] = temp; break; } index++; } } }
相关文章推荐
- 程序员不要仅靠经验,不多思考
- cf 19a World Football Cup
- Foundation 之 NSDictionary和NSMutableDictionary
- 创建git私有仓库
- 第十章、国际供应源搜寻中的风险和机会
- (转)Java读带有BOM的UTF-8文件乱码原因及解决方法
- [转] Eclipse的Tomcat插件安装
- lightoj 1356 - Prime Independence 【质因子分解 奇偶构图 + HK优化】
- 第118讲:Hadoop内存需求量及Namenode内存使用详解学习笔记
- maven配置问题
- 不用算术运算符实现两个数的加法(按位异或)
- android中图片的三级cache策略(内存、文件、网络)之三:文件缓存策略 .
- 二叉树中遇到的问题
- Notes on "Understanding the Linux kernel“
- 通过JMS监听Oracle AQ,在数据库变化时触发执行Java程序
- 仅在当前目录编译的通用Makefile
- Java 多维数组遍历
- 让开发板飞——四轴飞控原理
- 2015年10月23日作业
- 初窥Windows Server Container