金字塔程序

//金字塔程序:
public class Jinzita {

    public static void main(String[] args) {
        for (int a = 1; a < 10; a++) {
            for (int b = 0; b < (9 - a); b++) {
                System.out.print(" ");
            }
            for (int b = 1; b <= a; b++) {
                System.out.print(b);
            }
            for (int b = (a - 1); b > 0; b--) {
                System.out.print(b);
            }
            System.out.println();
        }
    }
}

 

posted on 2010-02-18 21:31  台哥编程课堂  阅读(183)  评论(0编辑  收藏  举报

导航