1 #include<stdio.h> 2 #include<string.h> 3 char a[85][85]; 4 int main() 5 { 6 int n,k=0,i,j; 7 char b,c,t; 8 while(~scanf("%d %c %c",&n,&b,&c)) 9 { 10 if(k++) 11 printf(" "); 12 if(n==1) 13 printf("%c ",b); 14 else 15 { 16 if(n%4==1)//判断外框字母 17 { 18 t=b; 19 b=c; 20 c=t; 21 } 22 for(i=0; i<n/2+1; ++i) 23 { 24 for(j=i; j<n-i; ++j) 25 a[i][j]=a[n-1-i][j]=a[j][i]=a[j][n-1-i]=i%2?b:c; 26 27 } 28 a[0][n-1]=a[0][0]=a[n-1][0]=a[n-1][n-1]=' '; 29 for(i=0; i<n; ++i) 30 { 31 for(j=0; j<n; ++j) 32 printf("%c",a[i][j]); 33 printf(" "); 34 } 35 } 36 } 37 }