@@ -0,0 +1,1809 @@
+/**%0A * Created by wm on 16/1/27.%0A * %3Cp/%3E%0A * #6 code%0A * 1   5%0A * 2 4 6%0A * 3   7%0A * %3Cp/%3E%0A * 1     7%0A * 2   6 8%0A * 3 5   9%0A * 4     10%0A * %3Cp/%3E%0A * 1 3 6%0A * 2 4 5%0A * %3Cp/%3E%0A * 1       9%0A * 2     8 10%0A * 3   7   11%0A * 4 6%0A * 5%0A */%0Apublic class ZigZag %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        String data = handle(%22PAYPALISHIRING%22, 1);%0A        CommonUtil.show(data);%0A    %7D%0A%0A%0A    private static String handle(String s, int numRows) %7B%0A%0A        if (s == null %7C%7C s.length() == 0 %7C%7C numRows %3C= 0) return %22%22;%0A%0A        if (numRows == 1) return s;%0A%0A        int length = s.length();%0A%0A        int pageNum = numRows + numRows - 2;%0A        int totalPage = length / pageNum;%0A%0A        if (s.length() %25 pageNum != 0)%0A            totalPage++;%0A%0A        //%E5%A4%9A%E6%9E%84%E9%80%A0%E5%87%BA%E6%9D%A5page%0A        // each unit is a rectangle%0A        int rows = numRows; // hang%0A        int cols = totalPage * (numRows - 1); // lie%0A        char%5B%5D%5B%5D map = new char%5Brows%5D%5Bcols%5D;%0A%0A        int x = 0;%0A%0A        int digt = 0;%0A%0A        for (int k = 1; k %3C= totalPage; k++) %7B%0A%0A            int startlie = (k - 1) * (numRows - 1);%0A%0A            x = 0;%0A%0A            for (int i = 0; i %3C pageNum; i++) %7B%0A                //%E6%AF%8F%E4%B8%AA%E6%9C%89%E8%BF%99%E5%A4%9A%E6%95%B0%0A                if (i %3C= numRows - 1) %7B%0A                    x = i;%0A                %7D else %7B%0A                    startlie++;%0A                    x = x - 1;%0A                %7D%0A%0A                if (digt %3C length) %7B%0A                    map%5Bx%5D%5Bstartlie%5D = s.charAt(digt);%0A                    digt++;%0A                %7D%0A            %7D%0A%0A%0A        %7D%0A%0A%0A        StringBuilder sb = new StringBuilder();%0A        for (int dd = 0; dd %3C rows; dd++) %7B%0A            for (int yy = 0; yy %3C cols; yy++) %7B%0A                if (map%5Bdd%5D%5Byy%5D != 0) %7B%0A                    sb.append(map%5Bdd%5D%5Byy%5D);%0A                %7D%0A            %7D%0A%0A        %7D%0A%0A        return sb.toString();%0A    %7D%0A%0A%7D%0A

add z shape logic