for循环语句输出菱形

时间:2023-03-09 16:18:11
for循环语句输出菱形
   for(int a = 5; a > 0 ; a--){
for(int b = 1; b <= a; b++){
System.out.print(" ");
}
for(int c = 5; c >= a; c--){
System.out.print("* ");
}
System.out.println(" ");
}
for(int a = 4; a > 0 ; a--){
for(int d = 1; d > 0; d--){ //这行for循环只是为了排版用的,实际意义不大
System.out.print(" ");
}
for(int b = 4; b >= a; b--){
System.out.print(" ");
}
for(int c = 1; c <= a; c++){
System.out.print("* ");
}
System.out.println("");
}

for循环语句输出菱形