解题思路:
注意事项:
参考代码:import java.util.Scanner;
public class C1788 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
F(sc.nextInt());
}
sc.close();
}
private static void F(int n){
System.out.println(n);
int len = 2*n - 1;
char[][] a = new char[len][len];
int min = 0, max = 0;
if(n % 2 == 0){
min = n - 2;
max = n;
}else{
min = n - 1;
max = n - 1;
}
while(min >= 0 && max <= len - 1){
for(int i = min; i <= max; i++){
a[min][i] = '*';
a[max][i] = '*';
a[i][min] = '*';
a[i][max] = '*';
}
min -= 2;
max += 2;
}
for(int i = 0; i
for(int j = 0; j
System.out.print(a[i][j] == '*' ? '*' : ' ');
}
System.out.println();
}
}
}