package sort;
import java.util.Arrays;
public class ShellSort {
public static void main(String[] args) {
int[] array = {1,22,41,21,411,5335,51,6,3,2121};
}
public static void shellSort(int[] a) {
for (int n = a.length / 2; n > 0; n /= 2) {
for (int i = n; i < a.length; i++) {
for (int j = i - n; j >= 0; j -= n) {
int k;
if (a[j] > a[j+n]) {
k = a[j];
a[j] = a[j+n];
a[j+n] = n;
}
}
}
}
System.out.println(Arrays.toString(a));
}
}
希尔排序(Java)
最新推荐文章于 2024-11-03 11:01:20 发布