-
C#排序算法 之 希尔排序
- using System;
-
- namespace ShellSorter
- {
- public class ShellSorter
- {
- public void Sort(int [] list)
- {
- int inc;
- for(inc=1;inc<=list.Length/9;inc=3*inc+1);
- for(;inc>0;inc/=3)
- {
- for(int i=inc+1;i<=list.Length;i+=inc)
- {
- int t=list[i-1];
- int j=i;
- while((j>inc)&&(list[j-inc-1]>t))
- {
- list[j-1]=list[j-inc-1];
- j-=inc;
- }
- list[j-1]=t;
- }
- }
- }
- }
-
- public class MainClass
- {
- public static void Main()
- {
- int[] iArrary=new int[]{1,5,13,6,10,55,99,2,87,12,34,75,33,47};
- ShellSorter sh=new ShellSorter();
- sh.Sort(iArrary);
- for(int m=0;m<iArrary.Length;m++)
- {
- Console.Write("{0} ",iArrary[m]);
- Console.WriteLine();
- }
- }
- }
- }
-
相关阅读:
计算一个数的逆序数的个数(1)
Javascript DOM(2)
python 装饰器
Javascript DOM
Javascrip 入门第三节课
C# sapnco支持.net 4.5了,真是个意外的发现
uft调用rfc接口
pyqt常用窗口组件
python QQTableView中嵌入复选框CheckBox四种方法
Pygame模块,功能表
-
原文地址:https://www.cnblogs.com/encounter/p/2188846.html
Copyright © 2020-2023
润新知