直接插入排序
来源:互联网 发布:拆分资金盘 php源码 编辑:程序博客网 时间:2024/05/29 03:20
#include <stdio.h>
void InsertSort(int a[],int size)
{
int x=1,y,m;
for(;x<size;x++)
{
y=x-1;
m=a[x];
while(a[y]>m&&y>=0)
{
a[y+1]=a[y];
y--;
}
a[y+1]=m;
}
}
int main()
{
int i;
int a[10]={3,29,29,60,10,91,11,43,34,76};
InsertSort(a,10);
for(i=0;i<10;i++)
{
printf("%d ",a[i]);
}
printf("\n");
return 0;
}
void InsertSort(int a[],int size)
{
int x=1,y,m;
for(;x<size;x++)
{
y=x-1;
m=a[x];
while(a[y]>m&&y>=0)
{
a[y+1]=a[y];
y--;
}
a[y+1]=m;
}
}
int main()
{
int i;
int a[10]={3,29,29,60,10,91,11,43,34,76};
InsertSort(a,10);
for(i=0;i<10;i++)
{
printf("%d ",a[i]);
}
printf("\n");
return 0;
}
0 0
- 插入排序--直接插入
- 插入排序------直接插入
- 插入排序---直接插入
- 排序:直接插入排序
- 排序---直接插入排序
- 排序 -- 直接插入排序
- 排序---直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序:直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 插入排序--直接插入排序
- 插入排序-直接插入排序
- Zend Studio 10.x注册码激活
- Cocos2d-x 3.0 安装与环境配置
- hdu 1381 Crazy Search(hash|map)
- @@servername serverproperty 不一致
- android 中文件加密 解密 算法实战
- 直接插入排序
- java中获取map的键值对方法
- linux开发之Valgrind代码使用内存检测的使用说明
- 一组PKCS#11 RSA签名测试数据
- PAT记录
- 3.6. Building RPMs from Source
- 50个必备的实用jQuery代码段+ 可以直接拿来用的15个jQuery代码片段
- linux下播放器设计和开发
- IPD流程在华为15年发展历程…