标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 14556 Accepted Submission(s):
3784
#include<stdio.h> #include<string.h> #define MAX 110 char s[MAX][MAX]; int main() { int n,m,j,i,t; char a,b,c; int ok=0; while(scanf("%d %c %c",&n,&a,&b)!=EOF) { if(ok) printf("\n"); ok=1; if(n==1) { printf("%c\n",a); continue; } memset(s,‘\0‘,sizeof(s)); m=(n+1)/2-1; s[m][m]=a; for(i=1;i<=m;i++) { if(i&1) c=b; else c=a; for(j=m-i;j<=m+i;j++) { s[m-i][j]=c; s[m+i][j]=c; s[j][m-i]=c; s[j][m+i]=c; } } s[0][0]=‘ ‘; s[0][n-1]=‘ ‘; s[n-1][0]=‘ ‘; s[n-1][n-1]=‘ ‘; for(i=0;i<n;i++) { puts(s[i]); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4677362.html