菱形“*”的编写
1 package com.yzy.test; 2 3 public class Rhombus{ 4 /** 5 * @param args 6 */ 7 public static void main(String[] args) { 8 // TODO Auto-generated method stub 9 int s = 9; 10 for (int i = 0; i < s; i++) { 11 for (int j = s - i; j > 0; j--) { 12 System.out.print(" "); 13 } 14 for (int j = 0; j < 2 * i + 1; j++) { 15 System.out.print("*"); 16 } 17 System.out.println(); 18 } 19 for (int i = s; i >= 0; i--) { 20 for (int j = 0; j < s - i; j++) { 21 System.out.print(" "); 22 } 23 for (int j = 0; j < 2 * i + 1; j++) { 24 System.out.print("*"); 25 } 26 System.out.println(); 27 } 28 } 29 30 }
运行结果:
待更新。。。。。。。。。。。。