public static void main(String[] args) {//菱形实心时,数量为1,2,3......
int a = 10;//菱形的边为10个 * for (int i = 1; i <= a; i++) { for (int j = 1; j <= a - i; j++) { System.out.print(" ");//打印空格 } for (int k = 1; k <= i; k++) { if (k == 1 || k == i) {//只有第一个和最后一个位置输出 * ,其他位置输出空格 System.out.print("* "); } else { System.out.print(" ");// 2倍的空格 } } System.out.println(); }//打印上半部分菱形(即三角形) for (int i = 1; i < a; i++) { for (int j = 1; j <= i; j++) { System.out.print(" "); } for (int m = 1; m <= a - i; m++) { if (m == 1 || m == a - i) { System.out.print("* "); } else { System.out.print(" ");//2倍的空格 } } System.out.println(); } }}