直接插入排序
来源:互联网 发布:淘宝 红包套现 熟人 编辑:程序博客网 时间:2024/05/16 15:04
class Program { static void Main(string[] args) { Random rd = new Random(); int[] a = new int[20]; for (int i = 0; i < a.Length ; i++) { a[i] = rd.Next(1, 100); } for (int i = 0; i < a.Length ; i++) { Console.Write(a[i] + " "); } InserSort(a, a.Length); Console.WriteLine(); for (int i = 0; i < a.Length ; i++) { Console.Write(a[i] + " "); } Console.ReadKey(); } static void InserSort(int[] a, int n) { int j, i, t; for (i = 1; i < n; i++) { t = a[i];//取出一个没有排序的数字 //在排序的序列中插入该数字,需要满足插入的位置比t小 for (j = i - 1; j >= 0 && t < a[j]; --j) { //小的数就往后排 a[j + 1] = a[j]; } //大的数就交换 a[j + 1] = t; } } }
0 0
- 插入排序--直接插入
- 插入排序------直接插入
- 插入排序---直接插入
- 排序:直接插入排序
- 排序---直接插入排序
- 排序 -- 直接插入排序
- 排序---直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序:直接插入排序
- 【排序】直接插入排序
- 排序--直接插入排序
- 排序--直接插入排序
- 排序-直接插入排序
- 插入排序--直接插入排序
- 插入排序-直接插入排序
- 星期几问题
- @Autowired注解、@Resource注解的区别
- MediaController
- 2.1jQuery 选择器
- 安装虚拟机VMware问题汇总
- 直接插入排序
- 模运算法则
- 浅谈大端小端
- Android SDK 在线更新镜像服务器资源:
- 使用 ZXing Android Embedded 实现二维码扫码
- 集合框架
- GLSurfaceView
- opendaylight(Li) l2switch 源代码分析(3)--packethandler
- JS鼠标提示框