#include <stdio.h> int main() { int a; int i, j, q; while (scanf("%d", &a) != EOF) { for (i = 1; i <= a; i++) { if (i == 1 || i == a) { for (j = 1; j <= a; j++) { printf("* "); } printf("\n"); } else { printf("* "); for (j = 2; j <= a -1; j++) { printf(" "); } printf("* \n"); } } } }
暴力输出