简单版本打印菱形

public class yhSJ {

    public static void main(String[] args) {
        for(int i = -3; i <= 3; i++){  //行   要上下一半 i=0
            for(int j = -4; j<= 4; j++){  //列   要左右一般 j=0
                System.out.print((Math.abs(i) + Math.abs(j) <= 3) ?"*":" ");   //小于行就OK  可以输出菱形
            }
            System.out.println();
        }
    }

}


posted @ 2013-03-06 13:34  Jason-Holt  阅读(145)  评论(0编辑  收藏  举报