打印字母金字塔
常数变易法思维
找规律
public class ConstantVariation02 {
public static void main(String[] args) {
//k = 0 1 2 3 4
//i = 7 6 5 4 3 i=7-k
//j = 1 3 5 7 9 j=2*k+1
for (int k = 0; k <5 ; k++) {//行数
for (int i = 0; i <7-k; i++) {
System.out.print(" ");
}
for (int j = 0; j <=(2*k+1)/2 ; j++) {
System.out.print((char)('A'+j));
}
for (int z =(2*k+1)/2-1; z>=0 ; z--) {
System.out.print((char)('A'+z));
}
System.out.println();
}
}
}