1   for(int a = 5; a > 0 ; a--){
 2             for(int b = 1; b <= a; b++){
 3                 System.out.print(" ");
 4              }
 5             for(int c = 5; c >= a; c--){
 6                 System.out.print("* ");
 7             }
 8             System.out.println(" ");
 9         }
10   for(int a = 4; a > 0 ; a--){
11             for(int d = 1; d > 0; d--){     //这行for循环只是为了排版用的,实际意义不大
12                 System.out.print(" ");
13             }
14             for(int b = 4; b >= a; b--){
15                 System.out.print(" ");
16              }
17             for(int c = 1; c <= a; c++){
18                 System.out.print("* ");
19             }
20             System.out.println("");
21         }

 

for循环语句输出菱形

相关文章:

  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
  • 2021-12-22
  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2022-12-23
  • 2021-11-10
  • 2021-06-24
  • 2022-12-23
相关资源
相似解决方案