package com.java; import java.util.Scanner; public class Test { public static void main(String[] args){ Scanner input =new Scanner(System.in); System.out.println("How long do you want side to be?"); int row=input.nextInt(); System.out.println("Please enter the character you want it to be made of:"); String str=input.next(); if(row>1){ for (int i = 0; i < row; i++) { for (int j = 0; j <= i; j++) { if( i >=2 && j !=0 && j!=i){ System.out.print(" "); }else{ System.out.print(str); } } System.out.println(); } for (int i =0; i<row-1; i++) { for (int j = 0; j <= i; j++) { System.out.print(" "); } for (int j = row-1; j >i; j--) { if(j==row-1 || j==i+1){ System.out.print(str); }else{ System.out.print(" "); } } System.out.println(); } }else{ System.out.println("至少为2!"); } } }