我的不完全AC代码
package 蓝桥基础;
import java.util.Scanner;
public class 字母图形1 {
public static void main(String []args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
char[] str = new char[]{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//虽然我知道这样存数很low,并且存完之后就想到了ASCII
int s = str.length;
for(int i = 0; i < n; i++) {
for(int l = i+1; l>0; l--) {
System.out.print(str[l-1]);
}
for(int k = 1; k < m; k++) {
System.out.print(str[k]);
}
m--;
System.out.println();
}
}
}
完全AC代码
package 蓝桥基础;
import java.util.Scanner;
public class 字母图形2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();//行数
int m = sc.nextInt();//列数
for(int i = 0 ; i < n; i++) {
for(int j = 0 ; j < m ;j++) {
char c = (char)(Math.abs(i - j) + 'A');
System.out.print(c);
}
System.out.println();
}
}
}