题目:
代码部分:
import java.util.Scanner;
public class Main{
public static void print(int n,char ch){
int n1=n;
for(int i = 1;i <= n;i++,n1--){
for(int j=1;j<=n-n1;j++){//(2*n-1-(2*n1-1))/2==n-n1
System.out.print(" ");
}
for(int j = 1 ;j <= 2*n1-1; j++){
System.out.print(ch);
}
System.out.println();
}
n1=n1+2;
for(int i = 2;i <= n;i++,n1++){
for(int j = 1;j <= n-n1;j++){
System.out.print(" ");
}
for(int j = 1 ;j <= 2*n1-1; j++){
System.out.print(ch);
}
System.out.println();
}
}
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
char st = sc.next().charAt(0);
int sum=0;
//2(2n-1)-1
int biao=0,yu=0;
for(int i = 1;sum<=n;i++){
sum=i*i*2-1;
biao=i;
}
biao--;
sum=biao*biao*2-1;
yu=n-sum;
print(biao,st);
System.out.println(yu);
}
}