简单版本打印菱形
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(); } } }
---------------------------------------------------------------------------------
Kind Regards,
HaiTao Niu
JavaScript developer :)
ORACLE Certified Database Administrator - 10g
SUN Certified Applocation Developer - Java 6
Ring Building,No.28,ZhongGuanCun Software Park, No.8 Dong Bei Wang West Road, Haidian District, Beijing P.R.China 100193
E-mail: 1648500@qq.com