直接插入排序(Straight Insert Sort)
来源:互联网 发布:联想旗舰店淘宝 编辑:程序博客网 时间:2024/06/04 18:12
原数列 1 7 3 6 2 5
第一次[1 7] 3 6 2 5
第二次[1 3 7] 6 2 5
第三次[1 3 6 7] 2 5
第四次[1 2 3 6 7] 5
第五次[1 2 3 5 6 7]
#include<stdio.h>//排序void InsertSort(int arr[], int length){int i = 0, j = 0, k = 0;for( i = 1; i < length; ++i){for(j = i - 1; j >= 0; --j)if (arr[j] < arr[i])break;if (j != i -1){int temp = arr[i];for(k = i -1; k > j; --k)arr[k + 1] = arr[k];arr[k + 1] = temp;}}}//打印输出void show(int arr[], int length){int loop = 0;for(loop = 0; loop < length; ++loop)printf("%d ", arr[loop]);}void main(){int arr[] = {23,43,47,25,13,44,26,85,35,77,55,28,94};int length = sizeof(arr)/sizeof(arr[0]);//数组元素个数 = 数组字节数 / 数组每个元素的字节数InsertSort(arr, length);show(arr,length);}
- 直接插入排序(Straight Insert Sort)
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 直接插入排序(Straight Insertion Sort)
- 1.插入排序—直接插入排序(Straight Insertion Sort)
- 插入排序—直接插入排序(Straight Insertion Sort)
- (直接)插入排序(Insert Sort)
- 排序之直接插入排序(Straight Insertion Sort)
- 排序(三)之直接插入排序Straight Insertion Sort
- 八大排序算法_直接插入排序(Straight Insertion Sort)
- 直接插入排序算法(Straight Insertion Sort) Java实现
- 直接插入排序(Straight InsertionSorting)
- 插入排序 直接插入排序的PHP实现 Straight Insertion Sort
- 冒泡排序(bubble sort)、直接插入排序(straight insertion sort)、简单选择排序(simple selection sort)
- 排序算法之 直接插入排序算法(Straight Insertion Sort):(Python)
- ubuntu 关机命令
- Ubuntu中root用户和user用户的相互切换
- Render Queue
- 蓝牙 Bluez
- 移植x264到vs2008
- 直接插入排序(Straight Insert Sort)
- RTMP中FLV流到标准h264、aac的转换
- Linux I/O Scheduler--CFQ(上)
- java.lang.ClassCastException: java.lang.Integer异常
- js变量类型转换
- 测试网站速度简单方法
- 图片加水印
- java 执行 cmd 命令
- Struts2基于注解的Action配置(一)