8-蓝桥杯-基础练习-字母图形-java
没啥技巧,就是找找规律
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
String[][] arr=new String[a][b];
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
if(j==0)
arr[i][j]=String.valueOf((char)(j+i+65));
else if(i<j)
arr[i][j]=String.valueOf((char)(j-i+65));
else
arr[i][j]=String.valueOf((char)(i-j+65));
}
}
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
System.out.print(arr[i][j]);
}
System.out.println();
}
}
}