题解 | #空心正方形图案#
空心正方形图案
http://www.nowcoder.com/practice/72347ee949dc47399186ee183632f303
#include<stdio.h>
int main()
{
int c, r, n;
while (scanf("%d", &n) != EOF)
{
for (r = 1; r <= n ;r++)
{
for (c = 1; c <= n; c++)
{
if (r == 1 || r == n || c == 1 || c == n)
printf("%-2c", '*');
else
printf(" ");
}
printf("\n");
}
}
return 0;
}