解题思路:
注意事项:对称输入,初始化都是.
参考代码:
import java.util.Scanner;
public class 输出米字形 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
char[][] ch = new char[2*n-1][2*n-1];
for(int i=0;i<2*n-1;i++)
for(int j=0;j<2*n-1;j++)
ch[i][j] ='.';
for(int i=0;i
ch[2*n-2-i][2*n-2-i] = ch[i][i] = ch[i][2*n-2-i] = ch[2*n-2-i][i] =
ch[i][n-1] = ch[2*n-2-i][n-1] = ch[n-1][i] = ch[n-1][2*n-2-i] = (char) ('A'+i);
for(int i=0;i<2*n-1;i++) {
for(int j=0;j<2*n-1;j++)
System.out.print(ch[i][j]);
System.out.println();
}
}
}