直接插入排序
来源:互联网 发布:出国留学知乎 编辑:程序博客网 时间:2024/06/11 17:50
//插入排序(简单实现)
//时间复杂度是O(n*n);
#include <stdio.h>
void Insert_sort(int *a,int n)
{
int i,j,key;
for(i=1;i<n;i++)
{
key=a[i];
for(j=i-1;j>=0;j--)
{
if(a[j]>=key)
a[j+1]=a[j];
else
break;
}
a[j+1]=key;
}
}
void main()
{
int a[]={5,2,4,6,1,9};
Insert_sort(a,6);
for(int i=0;i<6;i++)
printf("%d ",a[i]);
printf("\n");
}
0 0
- 插入排序--直接插入
- 插入排序------直接插入
- 插入排序---直接插入
- 排序:直接插入排序
- 排序---直接插入排序
- 排序 -- 直接插入排序
- 排序---直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序:直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 插入排序--直接插入排序
- 插入排序-直接插入排序
- hibernate中PO(持久化对象)与POJO(普通的JavaBean)
- 破解优酷土豆播放器过程
- Python超级程序员使用的开发工具
- 关于shm_open和shm_unlink的使用问题
- Oracle 11g新特性虚拟列分区
- 直接插入排序
- elasticsearch mapping
- C++中 char*,char[],string,CString转换
- MySQL远程连接不上解决办法
- android简单计算器
- 百度地图
- nyoj 吝啬的国度 http://blog.csdn.net/code_pang/article/details/7719221
- [LeetCode] Spiral Matrix II
- $Ajax,$get,$Post区别