@@ -0,0 +1,1294 @@
+package week2;%0A%0Aimport java.util.Random;%0A%0A/**%0A * Author: Mark%0A * Date  : 2015/3/2%0A * Time  : 19:41%0A */%0Apublic class ShellSort%3CItem extends Comparable%3C? super Item%3E%3E %7B%0A%0A%0A    public static void main(String%5B%5D args) %7B%0A        Integer%5B%5D items = new Integer%5B10%5D;%0A        Random random = new Random(47);%0A        for (int i = 0; i %3C 10; i++) %7B%0A            items%5Bi%5D = random.nextInt(50);%0A        %7D%0A        printArray(items);%0A        new ShellSort%3CInteger%3E().sort(items, 0, items.length);%0A        printArray(items);%0A    %7D%0A%0A    private static void printArray(Comparable%5B%5D items) %7B%0A        for (Comparable i : items) %7B%0A            System.out.print(i + %22 %22);%0A        %7D%0A        System.out.println();%0A    %7D%0A%0A%0A    public void sort(Item%5B%5D items, int low, int high) %7B%0A        if (low %3C 0 %7C%7C high %3E items.length %7C%7C low %3E high) %7B%0A            throw new IllegalArgumentException();%0A        %7D%0A        int gap = (high - low) / 2;%0A        for (int g = gap; g %3E 0; g--) %7B%0A            for (int i = low + g; i %3C high; i += g) %7B%0A                Item cur = items%5Bi%5D;%0A                int j = i - g;%0A                while (j %3E= low && items%5Bj%5D.compareTo(cur) %3E 0) %7B%0A                    items%5Bj + g%5D = items%5Bj%5D;%0A                    j -= g;%0A                %7D%0A                items%5Bj + g%5D = cur;%0A            %7D%0A        %7D%0A    %7D%0A%0A%7D%0A

add ShellSort