打印菱形
作者:互联网
public class Hellojava{ static final int rows=79; public static void main(String []arge) { int row; for(row=1;row<rows/2+1;row++) { for(int i=1;i<=(rows-2*row-1)/2;i++) System.out.print(" "); for(int j=0;j<2*row-1;j++) System.out.print("*"); System.out.print("\n"); } for(row-=2;row>=1;row--) { for(int i=1;i<=(rows-2*row-1)/2;i++) System.out.print(" "); for(int j=0;j<2*row-1;j++) System.out.print("*"); System.out.print("\n"); } } }
总行数rows 行数row 和 “*”数有关系 number=2row+1;和“ ”有关系number=(rows-2row-1)/2
标签:rows,int,打印,number,菱形,static,public,row 来源: https://www.cnblogs.com/wjqkaifa/p/15827931.html