希望对你有帮助
1040。。。
import java.util.*;
class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
char c = 64;
char x = 66;
int m = 0;
for (int i = 1; i <= n; i++)
{
m = i;
while (m>0)
{
m--;
c++;
}
for (int k = 1; k <= n-i; k++)
{
System.out.print(" ");
}
for (int j = 1; j <= i; j++)
{
System.out.print(c);
c--;
}
for (int p = 1; p < i; p++)
{
System.out.print(x);
x++;
}
x=66;
System.out.println();
}
}
}
1112
import java.util.*;
class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
char c = 65;
for (int i = 1; i <= n; i++)
{
for (int k = 1; k <= n-i; k++)
{
System.out.print(" ");
}
for (int j = 1; j <= i*2-1; j++)
{
System.out.print(c);
c++;
}
c = 65;
System.out.println();
}
}
}