1 package FushiExam; 2 import java.util.*; 3 public class Text_19 { 4 5 public static void main(String[] args) { 6 /*打印对称图案,输入n为,中间*的个数 7 * 如,输入:7 打印以下图案: 8 * * 9 * *** 10 * ***** 11 * ******* 奇数个 12 * ***** 13 * *** 14 * * 15 * 16 */ 17 System.out.println("输入一个奇数:"); 18 Scanner scan=new Scanner(System.in); 19 int count=scan.nextInt(); 20 if(count%2!=0) { 21 int x=count/2; 22 int sy=1,xy=count-2; 23 for(int i=x+1;i>=1;i--) {//上半部分 24 for(int j=i-1;j>0;j--) { 25 System.out.print(" "); 26 } 27 for(int k=1;k<=sy;k++) { 28 System.out.print("*"); 29 } 30 sy+=2; 31 System.out.println(); 32 } 33 for(int i=1;i<=x;i++) {//下半部分 34 for(int j=1;j<=i;j++) { 35 System.out.print(" ");//打印空格 36 } 37 for(int m=0;m<xy;m++) { 38 System.out.print("*"); 39 } 40 xy=xy-2; 41 System.out.println(); 42 } 43 44 } 45 else 46 System.out.println("data error!"); 47 } 48 }