- usingSystem;
- namespaceShellSorter
- {
- publicclassShellSorter
- {
- publicvoidSort(int[]list)
- {
- intinc;
- for(inc=1;inc<=list.Length/9;inc=3*inc+1);
- for(;inc>0;inc/=3)
- {
- for(inti=inc+1;i<=list.Length;i+=inc)
- {
- intt=list[i-1];
- intj=i;
- while((j>inc)&&(list[j-inc-1]>t))
- {
- list[j-1]=list[j-inc-1];
- j-=inc;
- }
- list[j-1]=t;
- }
- }
- }
- }
- publicclassMainClass
- {
- publicstaticvoidMain()
- {
- int[]iArrary=newint[]{1,5,13,6,10,55,99,2,87,12,34,75,33,47};
- ShellSortersh=newShellSorter();
- sh.Sort(iArrary);
- for(intm=0;m<iArrary.Length;m++)
- {
- Console.Write("{0}",iArrary[m]);
- Console.WriteLine();
- }
- }
- }
- }
C#排序算法 之 希尔排序
最新推荐文章于 2025-02-12 16:28:29 发布
本文介绍了一种名为希尔排序的排序算法实现,并通过一个具体的示例展示了如何使用该算法对整数数组进行排序。希尔排序是一种基于插入排序的高效算法,通过设置不同的增量序列来减少元素之间的比较次数。
部署运行你感兴趣的模型镜像
您可能感兴趣的与本文相关的镜像
Stable-Diffusion-3.5
图片生成
Stable-Diffusion
Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率
1041

被折叠的 条评论
为什么被折叠?



