标签:希尔排序 排序 TE blog har code public shellSort tps
https://blog.csdn.net/lucky51222/article/details/26110199
1. 构造算法类
class XiEr { public void ssort(int[] a, int n, int sp) { int i, j, t; for (i = 0; i < n - sp; i++) for (j = i; j < n - sp; j += sp) if (a[j] > a[j + sp]) { t = a[j]; a[j] = a[j + sp]; a[j + sp] = t; } } public void shellsort(int[] a, int n, int[] d, int dn) { int i; for (i = 0; i < dn; i++) ssort(a, n, d[i]); } }
2. 前端调用
int j; int[] a = { 49, 38, 100, 97, 76, 13, 27, 49, 55, 4 }; int[] d = { 5, 3, 1 }; XiEr xier = new XiEr(); xier.shellsort(a, 10, d, 3); listBox1.Items.Clear(); string tt = ""; for (j = 0; j < 10; j++) tt = tt + a[j].ToString() + ‘\t‘; listBox1.Items.Add(tt);
标签:希尔排序 排序 TE blog har code public shellSort tps
原文地址:https://www.cnblogs.com/CelonY/p/9219253.html