刚刚不是有个提问正三角形的吗? 和那个类似
import java.util.Scanner;
class Demo {
public static void main(String[] args) {
System.out.println(" 请输入一个正奇整数:");
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if (a >= 0 && a%2 == 1) {
for (int i = 1; i <= a; i++) {
int y = java.lang.Math.abs((a + 1)/2 - i);
for (int b=1; b <= y; b++) {
System.out.print(" ");
}
for (int c=1; c <= (a - 2*y); c++) {
System.out.print("*");
}
for (int d=1; d <= y; d++) {
System.out.print(" ");
}
System.out.println();