题解 | 空心正方形图案
空心正方形图案
https://www.nowcoder.com/practice/72347ee949dc47399186ee183632f303
#include <stdio.h>
int main() {
int a = 0;
int i = 0;
char arr[2] = {'*',' '};
while (scanf("%d", &a) != EOF) { // 注意 while 处理多个 case
// 64 位输出请用 printf("%lld") to
for(i = 0;i < a;i++){
for(int j = 0;j < a;j++){
if (i == 0 || i == a - 1) {
printf("%c ",arr[0]);
}
else {
if (j == 0 || j == a - 1) {
printf("%c ",arr[0]);
}
else {
printf(" ");
}
}
}
printf("\n");
}
}
return 0;
}