java - 打印菱形(标题重复率高)

tech2023-10-19  88

package cn.tedu.basics; //打印菱形 public class Test_ForInFor { public static void main(String[] args) { for (int i = 0; i < 4; i++) { for (int j = 4; j > i + 1; j--) { System.out.print(" "); } for (int x = 0; x < i * 2 + 1; x++) { System.out.print("*"); } System.out.println(); } for (int i = 0; i < 3; i++) { for (int j = 0; j < i + 1; j++) { System.out.print(" "); } for (int x = 5; x > 2 * i; x--) { System.out.print("*"); } System.out.println(); } } }
最新回复(0)