JAVA课程04

package For语句数字金字塔;

public class For语句数字金字塔 {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        for (int h = 1; h <= 5; h++) {
            for (int k = 0; k < 5 - h; k++)
            System.out.print(" ");
            for (int x = 0; x < h; x++) {
            System.out.print(x * 2 + 1);
            }
            for (int x = h - 1; x > 0; x--) {
            System.out.print(x * 2 - 1);
            }
            System.out.println();
        }
    }

}

 

posted @ 2019-03-08 20:24  JAYPARK01  阅读(145)  评论(0编辑  收藏  举报