/* 编写程序,输出下图菱形: * *** ***** ******* ********* ******* ***** *** * */ class 输出菱形{ public static void main(String[] args) { //输出正三角 for (int i = 1; i <= 5 ; i++) { //本循环输出空格 for (int j = 1; j <= 5 - i ; j++) { System.out.print(" "); } //本循环输出* for (int j = 1; j <= 2 * i - 1 ; j++) { System.out.print("*"); } System.out.println(); } //输出倒三角 for (int i = 1; i <= 4 ; i++) { //输出空格 for (int j = 1; j <= i; j++) { System.out.print(" "); } //输出* for (int j = 1; j <= 2 * (4 - i) + 1 ; j++) { System.out.print("*"); } System.out.println(); } } }