@@ -0,0 +1,1200 @@
+package qiyuesuanfa.array;%0A%0Aimport easy.CommonUtil;%0A%0A/**%0A * Created by wm on 16/4/6.%0A * %E8%8D%B7%E5%85%B0%E5%9B%BD%E6%97%97%EF%BC%8C %E4%B8%89%E4%B8%AA%E6%95%B0 %E6%8E%92%E5%88%97%0A */%0Apublic class ThreeNumber %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        int%5B%5D array = new int%5B%5D%7B0, 1, 0, 2, 0, 2, 1, 2, 1%7D;%0A        CommonUtil.show(array);%0A        handle(array);%0A        CommonUtil.show(array);%0A    %7D%0A%0A    /**%0A     * %E6%95%B0%E6%8D%AE%E5%AF%B9%E6%AF%94%EF%BC%8C%E5%88%92%E5%88%86%EF%BC%8C%0A     *%0A     * @param array%0A     */%0A    public static void handle(int%5B%5D array) %7B%0A        int len = array.length;%0A        int begin = 0;%0A        int cur = 0;%0A        int end = len - 1;%0A%0A        while (cur %3C= end) %7B%0A            if (array%5Bcur%5D == 2) %7B%0A                swap(array, cur, end);%0A                end--;%0A            %7D else if (array%5Bcur%5D == 1) %7B%0A                cur++;%0A            %7D else %7B%0A                // %E8%BF%99%E9%87%8C%E7%9A%84%E6%AF%94%E8%BE%83%E5%8F%AF%E4%BB%A5%E4%BC%98%E5%8C%96%E5%A4%84%E7%90%86%0A                if (begin == cur) %7B%0A                    begin++;%0A                    cur++;%0A                %7D else %7B%0A                    swap(array, begin, cur);%0A                    begin++;%0A                    cur++;%0A                %7D%0A            %7D%0A        %7D%0A%0A    %7D%0A%0A    public static void swap(int%5B%5D array, int x, int y) %7B%0A        int temp = array%5Bx%5D;%0A        array%5Bx%5D = array%5By%5D;%0A        array%5By%5D = temp;%0A    %7D%0A%0A%7D%0A

add array huafen