java输出菱形
1 package test; 2 3 public class Test { 4 public static void main(String[] args) { 5 for(int i=1;i<=4;i++){ 6 for(int k=1;k<=4-i;k++){ 7 System.out.print(" "+" "); 8 } 9 for(int j=1;j<=2*i-1;j++){ 10 11 System.out.print("*"+" "); 12 } 13 System.out.println(); 14 } 15 for(int i=1;i<=3;i++){ 16 for(int k=1;k<=i;k++){ 17 System.out.print(" "+" "); 18 } 19 for(int j=1;j<=7-2*i;j++){ 20 System.out.print("*"+" "); 21 } 22 System.out.println(); 23 } 24 } 25 }